From edc631f6619206108ea39e359b6857a9556f4b95 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Wed, 21 Aug 2019 15:13:11 -0700 Subject: [PATCH] yarn dist --- dist/nearlib.js | 13671 ++++------------ dist/nearlib.min.js | 199 +- docs/SUMMARY.md | 23 + docs/classes/_account_.account.md | 77 +- .../_account_creator_.accountcreator.md | 2 +- .../_account_creator_.localaccountcreator.md | 8 +- .../_account_creator_.urlaccountcreator.md | 8 +- docs/classes/_connection_.connection.md | 10 +- docs/classes/_contract_.contract.md | 6 +- ..._key_store_.browserlocalstoragekeystore.md | 22 +- ...s_in_memory_key_store_.inmemorykeystore.md | 16 +- .../classes/_key_stores_keystore_.keystore.md | 12 +- ...y_stores_merge_key_store_.mergekeystore.md | 16 +- ...keystore_.unencryptedfilesystemkeystore.md | 18 +- docs/classes/_near_.near.md | 18 +- ...ders_json_rpc_provider_.jsonrpcprovider.md | 22 +- docs/classes/_providers_provider_.provider.md | 16 +- docs/classes/_signer_.inmemorysigner.md | 12 +- docs/classes/_signer_.signer.md | 8 +- docs/classes/_transaction_.accesskey.md | 51 + .../_transaction_.accesskeypermission.md | 62 + docs/classes/_transaction_.action.md | 116 + docs/classes/_transaction_.addkey.md | 51 + docs/classes/_transaction_.assignable.md | 38 + docs/classes/_transaction_.createaccount.md | 30 + docs/classes/_transaction_.deleteaccount.md | 42 + docs/classes/_transaction_.deletekey.md | 42 + docs/classes/_transaction_.deploycontract.md | 42 + docs/classes/_transaction_.enum.md | 42 + .../_transaction_.fullaccesspermission.md | 30 + docs/classes/_transaction_.functioncall.md | 69 + .../_transaction_.functioncallpermission.md | 60 + docs/classes/_transaction_.iaction.md | 46 + docs/classes/_transaction_.publickey.md | 47 + docs/classes/_transaction_.signature.md | 47 + .../_transaction_.signedtransaction.md | 65 + docs/classes/_transaction_.stake.md | 51 + docs/classes/_transaction_.transaction.md | 78 + docs/classes/_transaction_.transfer.md | 42 + docs/classes/_utils_key_pair_.keypair.md | 12 +- .../_utils_key_pair_.keypaired25519.md | 18 +- .../classes/_utils_serialize_.binaryreader.md | 156 + .../classes/_utils_serialize_.binarywriter.md | 203 + .../classes/_wallet_account_.walletaccount.md | 24 +- ...viders_provider_.finaltransactionstatus.md | 8 +- docs/enums/_transaction_.keytype.md | 22 + docs/interfaces/_account_.accountstate.md | 32 +- ...ypted_file_system_keystore_.accountinfo.md | 4 +- .../_providers_provider_.blockheader.md | 18 +- .../_providers_provider_.blockresult.md | 4 +- ...viders_provider_.finaltransactionresult.md | 4 +- .../_providers_provider_.nodestatusresult.md | 8 +- .../_providers_provider_.syncinfo.md | 10 +- .../_providers_provider_.totalweight.md | 2 +- .../_providers_provider_.transaction.md | 8 +- .../_providers_provider_.transactionlog.md | 8 +- docs/interfaces/_utils_key_pair_.signature.md | 4 +- docs/interfaces/_utils_network_.network.md | 6 +- docs/interfaces/_utils_web_.connectioninfo.md | 12 +- docs/modules/_account_.md | 12 +- docs/modules/_connection_.md | 4 +- ...stores_browser_local_storage_key_store_.md | 2 +- ...tores_unencrypted_file_system_keystore_.md | 18 +- docs/modules/_near_.md | 2 +- docs/modules/_providers_json_rpc_provider_.md | 2 +- docs/modules/_providers_provider_.md | 2 +- docs/modules/_transaction_.md | 768 +- docs/modules/_utils_key_pair_.md | 2 +- docs/modules/_utils_serialize_.md | 154 +- docs/modules/_utils_web_.md | 4 +- docs/modules/_wallet_account_.md | 6 +- lib/account.d.ts | 2 +- lib/account.js | 8 +- lib/transaction.d.ts | 2 +- lib/transaction.js | 38 +- lib/utils/serialize.d.ts | 4 +- lib/utils/serialize.js | 32 +- 77 files changed, 5597 insertions(+), 11243 deletions(-) create mode 100644 docs/classes/_transaction_.accesskey.md create mode 100644 docs/classes/_transaction_.accesskeypermission.md create mode 100644 docs/classes/_transaction_.action.md create mode 100644 docs/classes/_transaction_.addkey.md create mode 100644 docs/classes/_transaction_.assignable.md create mode 100644 docs/classes/_transaction_.createaccount.md create mode 100644 docs/classes/_transaction_.deleteaccount.md create mode 100644 docs/classes/_transaction_.deletekey.md create mode 100644 docs/classes/_transaction_.deploycontract.md create mode 100644 docs/classes/_transaction_.enum.md create mode 100644 docs/classes/_transaction_.fullaccesspermission.md create mode 100644 docs/classes/_transaction_.functioncall.md create mode 100644 docs/classes/_transaction_.functioncallpermission.md create mode 100644 docs/classes/_transaction_.iaction.md create mode 100644 docs/classes/_transaction_.publickey.md create mode 100644 docs/classes/_transaction_.signature.md create mode 100644 docs/classes/_transaction_.signedtransaction.md create mode 100644 docs/classes/_transaction_.stake.md create mode 100644 docs/classes/_transaction_.transaction.md create mode 100644 docs/classes/_transaction_.transfer.md create mode 100644 docs/classes/_utils_serialize_.binaryreader.md create mode 100644 docs/classes/_utils_serialize_.binarywriter.md create mode 100644 docs/enums/_transaction_.keytype.md diff --git a/dist/nearlib.js b/dist/nearlib.js index a19bb7f184..546c1aa21e 100644 --- a/dist/nearlib.js +++ b/dist/nearlib.js @@ -5,21 +5,17 @@ window.nearlib = require('./lib/index'); window.Buffer = Buffer; }).call(this,require("buffer").Buffer) -},{"./lib/index":6,"buffer":39,"error-polyfill":46}],2:[function(require,module,exports){ +},{"./lib/index":6,"buffer":31,"error-polyfill":38}],2:[function(require,module,exports){ (function (Buffer){ 'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -const bn_js_1 = __importDefault(require("bn.js")); const transaction_1 = require("./transaction"); const provider_1 = require("./providers/provider"); const serialize_1 = require("./utils/serialize"); // Default amount of tokens to be send with the function calls. Used to pay for the fees // incurred while running the contract execution. The unused amount will be refunded back to // the originator. -const DEFAULT_FUNC_CALL_AMOUNT = new bn_js_1.default(1000000000); +const DEFAULT_FUNC_CALL_AMOUNT = 1000000; // Default number of retries before giving up on a transactioin. const TX_STATUS_RETRY_NUMBER = 10; // Default wait until next retry in millis. @@ -39,10 +35,14 @@ class Account { this.accountId = accountId; } async fetchState() { - const state = await this.connection.provider.query(`account/${this.accountId}`, ''); - this._state = state; - this._state.amount = state.amount; - this._state.stake = state.stake; + this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); + try { + const publicKey = await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId); + this._accessKey = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); + } + catch { + this._accessKey = null; + } } async state() { await this.ready; @@ -67,8 +67,12 @@ class Account { } throw new Error(`Exceeded ${TX_STATUS_RETRY_NUMBER} status check attempts for transaction ${serialize_1.base_encode(txHash)}.`); } - async signAndSendTransaction(transaction) { - const [txHash, signedTx] = await transaction_1.signTransaction(this.connection.signer, transaction, this.accountId, this.connection.networkId); + async signAndSendTransaction(receiverId, actions) { + await this.ready; + if (this._accessKey === null) { + throw new Error(`Can not sign transactions, initialize account with available public key in Signer.`); + } + const [txHash, signedTx] = await transaction_1.signTransaction(receiverId, ++this._accessKey.nonce, actions, this.connection.signer, this.accountId, this.connection.networkId); let result; try { result = await this.connection.provider.sendTransaction(signedTx); @@ -81,18 +85,12 @@ class Account { throw error; } } - const flatLogs = result.logs.reduce((acc, it) => acc.concat(it.lines), []); - if (transaction.hasOwnProperty('contractId')) { - this.printLogs(transaction['contractId'], flatLogs); - } - else if (transaction.hasOwnProperty('originator')) { - this.printLogs(transaction['originator'], flatLogs); - } + const flatLogs = result.transactions.reduce((acc, it) => acc.concat(it.result.logs), []); + this.printLogs(signedTx.transaction.receiverId, flatLogs); if (result.status === provider_1.FinalTransactionStatus.Failed) { - if (result.logs) { - console.warn(flatLogs); + if (flatLogs) { const errorMessage = flatLogs.find(it => it.startsWith('ABORT:')) || flatLogs.find(it => it.startsWith('Runtime error:')) || ''; - throw new Error(`Transaction ${result.logs[0].hash} failed. ${errorMessage}`); + throw new Error(`Transaction ${result.transactions[0].hash} failed. ${errorMessage}`); } } // TODO: if Tx is Unknown or Started. @@ -106,44 +104,38 @@ class Account { await contractAccount.deployContract(data); return contractAccount; } - async sendMoney(receiver, amount) { - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.sendMoney(this._state.nonce, this.accountId, receiver, amount)); + async sendMoney(receiverId, amount) { + return this.signAndSendTransaction(receiverId, [transaction_1.transfer(amount)]); } async createAccount(newAccountId, publicKey, amount) { - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.createAccount(this._state.nonce, this.accountId, newAccountId, publicKey, amount)); + const accessKey = transaction_1.fullAccessKey(); + return this.signAndSendTransaction(newAccountId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(publicKey, accessKey)]); } async deployContract(data) { - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.deployContract(this._state.nonce, this.accountId, data)); + return this.signAndSendTransaction(this.accountId, [transaction_1.deployContract(data)]); } - async functionCall(contractId, methodName, args, amount) { + async functionCall(contractId, methodName, args, gas, amount) { if (!args) { args = {}; } - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.functionCall(this._state.nonce, this.accountId, contractId, methodName, Buffer.from(JSON.stringify(args)), amount || DEFAULT_FUNC_CALL_AMOUNT)); + return this.signAndSendTransaction(contractId, [transaction_1.functionCall(methodName, Buffer.from(JSON.stringify(args)), gas || DEFAULT_FUNC_CALL_AMOUNT, amount)]); } - async addKey(publicKey, contractId, methodName, balanceOwner, amount) { - await this.ready; - this._state.nonce++; - const accessKey = contractId ? transaction_1.createAccessKey(contractId, methodName, balanceOwner, amount) : null; - return this.signAndSendTransaction(transaction_1.addKey(this._state.nonce, this.accountId, publicKey, accessKey)); + // TODO: expand this API to support more options. + async addKey(publicKey, contractId, methodName, amount) { + let accessKey; + if (contractId === null || contractId === undefined) { + accessKey = transaction_1.fullAccessKey(); + } + else { + accessKey = transaction_1.functionCallAccessKey(contractId, !methodName ? [] : [methodName], amount); + } + return this.signAndSendTransaction(this.accountId, [transaction_1.addKey(publicKey, accessKey)]); } async deleteKey(publicKey) { - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.deleteKey(this._state.nonce, this.accountId, publicKey)); + return this.signAndSendTransaction(this.accountId, [transaction_1.deleteKey(publicKey)]); } async stake(publicKey, amount) { - await this.ready; - this._state.nonce++; - return this.signAndSendTransaction(transaction_1.stake(this._state.nonce, this.accountId, amount, publicKey)); + return this.signAndSendTransaction(this.accountId, [transaction_1.stake(amount, publicKey)]); } async viewFunction(contractId, methodName, args) { const result = await this.connection.provider.query(`call/${contractId}/${methodName}`, serialize_1.base_encode(JSON.stringify(args))); @@ -152,15 +144,25 @@ class Account { } return JSON.parse(Buffer.from(result.result).toString()); } - async getAccountDetails() { + /// Returns array of {access_key: AccessKey, public_key: PublicKey} items. + async getAccessKeys() { const response = await this.connection.provider.query(`access_key/${this.accountId}`, ''); + return response; + } + async getAccountDetails() { + // TODO: update the response value to return all the different keys, not just app keys. + // Also if we need this function, or getAccessKeys is good enough. + const accessKeys = await this.getAccessKeys(); const result = { authorizedApps: [], transactions: [] }; - Object.keys(response).forEach((key) => { - result.authorizedApps.push({ - contractId: response[key][1].contract_id, - amount: response[key][1].amount, - publicKey: serialize_1.base_encode(response[key][0]), - }); + accessKeys.map((item) => { + if (item.access_key.permission.FunctionCall !== undefined) { + const perm = item.access_key.permission.FunctionCall; + result.authorizedApps.push({ + contractId: perm.receiver_id, + amount: perm.allowance, + publicKey: item.public_key.data, + }); + } }); return result; } @@ -168,7 +170,7 @@ class Account { exports.Account = Account; }).call(this,require("buffer").Buffer) -},{"./providers/provider":17,"./transaction":19,"./utils/serialize":23,"bn.js":35,"buffer":39}],3:[function(require,module,exports){ +},{"./providers/provider":16,"./transaction":18,"./utils/serialize":22,"buffer":31}],3:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -234,7 +236,7 @@ class Connection { } exports.Connection = Connection; -},{"./providers":15,"./signer":18}],5:[function(require,module,exports){ +},{"./providers":14,"./signer":17}],5:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); const providers_1 = require("./providers"); @@ -263,7 +265,7 @@ class Contract { } exports.Contract = Contract; -},{"./providers":15}],6:[function(require,module,exports){ +},{"./providers":14}],6:[function(require,module,exports){ 'use strict'; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; @@ -279,6 +281,8 @@ const utils = __importStar(require("./utils")); exports.utils = utils; const keyStores = __importStar(require("./key_stores")); exports.keyStores = keyStores; +const transactions = __importStar(require("./transaction")); +exports.transactions = transactions; const account_1 = require("./account"); exports.Account = account_1.Account; const accountCreator = __importStar(require("./account_creator")); @@ -297,7 +301,7 @@ exports.connect = near_1.connect; const wallet_account_1 = require("./wallet-account"); exports.WalletAccount = wallet_account_1.WalletAccount; -},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./near":13,"./providers":15,"./signer":18,"./utils":20,"./utils/key_pair":21,"./wallet-account":25}],7:[function(require,module,exports){ +},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./near":13,"./providers":14,"./signer":17,"./transaction":18,"./utils":19,"./utils/key_pair":20,"./wallet-account":24}],7:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); const keystore_1 = require("./keystore"); @@ -362,7 +366,7 @@ class BrowserLocalStorageKeyStore extends keystore_1.KeyStore { } exports.BrowserLocalStorageKeyStore = BrowserLocalStorageKeyStore; -},{"../utils/key_pair":21,"./keystore":10}],8:[function(require,module,exports){ +},{"../utils/key_pair":20,"./keystore":10}],8:[function(require,module,exports){ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); const keystore_1 = require("./keystore"); @@ -412,7 +416,7 @@ class InMemoryKeyStore extends keystore_1.KeyStore { } exports.InMemoryKeyStore = InMemoryKeyStore; -},{"../utils/key_pair":21,"./keystore":10}],9:[function(require,module,exports){ +},{"../utils/key_pair":20,"./keystore":10}],9:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const keystore_1 = require("./keystore"); @@ -586,7 +590,7 @@ class UnencryptedFileSystemKeyStore extends keystore_1.KeyStore { } exports.UnencryptedFileSystemKeyStore = UnencryptedFileSystemKeyStore; -},{"../utils/key_pair":21,"./keystore":10,"fs":37,"util":86}],13:[function(require,module,exports){ +},{"../utils/key_pair":20,"./keystore":10,"fs":29,"util":67}],13:[function(require,module,exports){ "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -691,7862 +695,2056 @@ async function connect(config) { } exports.connect = connect; -},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./key_stores/unencrypted_file_system_keystore":12,"./utils/key_pair":21,"bn.js":35}],14:[function(require,module,exports){ -/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./key_stores/unencrypted_file_system_keystore":12,"./utils/key_pair":20,"bn.js":27}],14:[function(require,module,exports){ "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const provider_1 = require("./provider"); +exports.Provider = provider_1.Provider; +exports.getTransactionLastResult = provider_1.getTransactionLastResult; +const json_rpc_provider_1 = require("./json-rpc-provider"); +exports.JsonRpcProvider = json_rpc_provider_1.JsonRpcProvider; -var $protobuf = require("protobufjs/minimal"); - -// Common aliases -var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; - -// Exported root namespace -var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {}); - -$root.CreateAccountTransaction = (function() { - - /** - * Properties of a CreateAccountTransaction. - * @exports ICreateAccountTransaction - * @interface ICreateAccountTransaction - * @property {number|Long|null} [nonce] CreateAccountTransaction nonce - * @property {string|null} [originator] CreateAccountTransaction originator - * @property {string|null} [newAccountId] CreateAccountTransaction newAccountId - * @property {IUint128|null} [amount] CreateAccountTransaction amount - * @property {Uint8Array|null} [publicKey] CreateAccountTransaction publicKey - */ - - /** - * Constructs a new CreateAccountTransaction. - * @exports CreateAccountTransaction - * @classdesc Represents a CreateAccountTransaction. - * @implements ICreateAccountTransaction - * @constructor - * @param {ICreateAccountTransaction=} [properties] Properties to set - */ - function CreateAccountTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; +},{"./json-rpc-provider":15,"./provider":16}],15:[function(require,module,exports){ +(function (Buffer){ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const provider_1 = require("./provider"); +const web_1 = require("../utils/web"); +const serialize_1 = require("../utils/serialize"); +/// Keep ids unique across all connections. +let _nextId = 123; +class JsonRpcProvider extends provider_1.Provider { + constructor(url, network) { + super(); + // TODO: resolve network to url... + this.connection = { url }; } - - /** - * CreateAccountTransaction nonce. - * @member {number|Long} nonce - * @memberof CreateAccountTransaction - * @instance - */ - CreateAccountTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * CreateAccountTransaction originator. - * @member {string} originator - * @memberof CreateAccountTransaction - * @instance - */ - CreateAccountTransaction.prototype.originator = ""; - - /** - * CreateAccountTransaction newAccountId. - * @member {string} newAccountId - * @memberof CreateAccountTransaction - * @instance - */ - CreateAccountTransaction.prototype.newAccountId = ""; - - /** - * CreateAccountTransaction amount. - * @member {IUint128|null|undefined} amount - * @memberof CreateAccountTransaction - * @instance - */ - CreateAccountTransaction.prototype.amount = null; - - /** - * CreateAccountTransaction publicKey. - * @member {Uint8Array} publicKey - * @memberof CreateAccountTransaction - * @instance - */ - CreateAccountTransaction.prototype.publicKey = $util.newBuffer([]); - - /** - * Creates a new CreateAccountTransaction instance using the specified properties. - * @function create - * @memberof CreateAccountTransaction - * @static - * @param {ICreateAccountTransaction=} [properties] Properties to set - * @returns {CreateAccountTransaction} CreateAccountTransaction instance - */ - CreateAccountTransaction.create = function create(properties) { - return new CreateAccountTransaction(properties); - }; - - /** - * Encodes the specified CreateAccountTransaction message. Does not implicitly {@link CreateAccountTransaction.verify|verify} messages. - * @function encode - * @memberof CreateAccountTransaction - * @static - * @param {ICreateAccountTransaction} message CreateAccountTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CreateAccountTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.newAccountId != null && message.hasOwnProperty("newAccountId")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.newAccountId); - if (message.amount != null && message.hasOwnProperty("amount")) - $root.Uint128.encode(message.amount, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.publicKey); - return writer; - }; - - /** - * Encodes the specified CreateAccountTransaction message, length delimited. Does not implicitly {@link CreateAccountTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof CreateAccountTransaction - * @static - * @param {ICreateAccountTransaction} message CreateAccountTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - CreateAccountTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a CreateAccountTransaction message from the specified reader or buffer. - * @function decode - * @memberof CreateAccountTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {CreateAccountTransaction} CreateAccountTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CreateAccountTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.CreateAccountTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.newAccountId = reader.string(); - break; - case 4: - message.amount = $root.Uint128.decode(reader, reader.uint32()); - break; - case 5: - message.publicKey = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } + async getNetwork() { + return { + name: 'test', + chainId: 'test' + }; + } + async status() { + return this.sendJsonRpc('status', []); + } + async sendTransaction(signedTransaction) { + const bytes = signedTransaction.encode(); + return this.sendJsonRpc('broadcast_tx_commit', [Buffer.from(bytes).toString('base64')]); + } + async txStatus(txHash) { + return this.sendJsonRpc('tx', [serialize_1.base_encode(txHash)]); + } + async query(path, data) { + const result = await this.sendJsonRpc('query', [path, data]); + if (result.error) { + throw new Error(`Quering ${path} failed: ${result.error}.\n${JSON.stringify(result, null, 2)}`); } - return message; - }; - - /** - * Decodes a CreateAccountTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof CreateAccountTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {CreateAccountTransaction} CreateAccountTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - CreateAccountTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a CreateAccountTransaction message. - * @function verify - * @memberof CreateAccountTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - CreateAccountTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.newAccountId != null && message.hasOwnProperty("newAccountId")) - if (!$util.isString(message.newAccountId)) - return "newAccountId: string expected"; - if (message.amount != null && message.hasOwnProperty("amount")) { - var error = $root.Uint128.verify(message.amount); - if (error) - return "amount." + error; + return result; + } + async block(height) { + return this.sendJsonRpc('block', [height]); + } + async sendJsonRpc(method, params) { + const request = { + method, + params, + id: (_nextId++), + jsonrpc: '2.0' + }; + const result = await web_1.fetchJson(this.connection, JSON.stringify(request)); + if (result.error) { + throw new Error(`[${result.error.code}] ${result.error.message}: ${result.error.data}`); } - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - if (!(message.publicKey && typeof message.publicKey.length === "number" || $util.isString(message.publicKey))) - return "publicKey: buffer expected"; - return null; - }; + return result.result; + } +} +exports.JsonRpcProvider = JsonRpcProvider; - /** - * Creates a CreateAccountTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof CreateAccountTransaction - * @static - * @param {Object.} object Plain object - * @returns {CreateAccountTransaction} CreateAccountTransaction - */ - CreateAccountTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.CreateAccountTransaction) - return object; - var message = new $root.CreateAccountTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.newAccountId != null) - message.newAccountId = String(object.newAccountId); - if (object.amount != null) { - if (typeof object.amount !== "object") - throw TypeError(".CreateAccountTransaction.amount: object expected"); - message.amount = $root.Uint128.fromObject(object.amount); +}).call(this,require("buffer").Buffer) +},{"../utils/serialize":22,"../utils/web":23,"./provider":16,"buffer":31}],16:[function(require,module,exports){ +(function (Buffer){ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +var FinalTransactionStatus; +(function (FinalTransactionStatus) { + FinalTransactionStatus["Unknown"] = "Unknown"; + FinalTransactionStatus["Started"] = "Started"; + FinalTransactionStatus["Failed"] = "Failed"; + FinalTransactionStatus["Completed"] = "Completed"; +})(FinalTransactionStatus = exports.FinalTransactionStatus || (exports.FinalTransactionStatus = {})); +class Provider { +} +exports.Provider = Provider; +function getTransactionLastResult(txResult) { + for (let i = txResult.logs.length - 1; i >= 0; --i) { + const r = txResult.logs[i]; + if (r.result && r.result.length > 0) { + return JSON.parse(Buffer.from(r.result).toString()); } - if (object.publicKey != null) - if (typeof object.publicKey === "string") - $util.base64.decode(object.publicKey, message.publicKey = $util.newBuffer($util.base64.length(object.publicKey)), 0); - else if (object.publicKey.length) - message.publicKey = object.publicKey; - return message; - }; + } + return null; +} +exports.getTransactionLastResult = getTransactionLastResult; +}).call(this,require("buffer").Buffer) +},{"buffer":31}],17:[function(require,module,exports){ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const js_sha256_1 = __importDefault(require("js-sha256")); +const key_pair_1 = require("./utils/key_pair"); +/** + * General signing interface, can be used for in memory signing, RPC singing, external wallet, HSM, etc. + */ +class Signer { /** - * Creates a plain object from a CreateAccountTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof CreateAccountTransaction - * @static - * @param {CreateAccountTransaction} message CreateAccountTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object + * Signs given message, by first hashing with sha256. + * @param message message to sign. + * @param accountId accountId to use for signing. + * @param networkId network for this accontId. */ - CreateAccountTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - object.newAccountId = ""; - object.amount = null; - if (options.bytes === String) - object.publicKey = ""; - else { - object.publicKey = []; - if (options.bytes !== Array) - object.publicKey = $util.newBuffer(object.publicKey); - } + async signMessage(message, accountId, networkId) { + return this.signHash(new Uint8Array(js_sha256_1.default.sha256.array(message)), accountId, networkId); + } +} +exports.Signer = Signer; +/** + * Signs using in memory key store. + */ +class InMemorySigner extends Signer { + constructor(keyStore) { + super(); + this.keyStore = keyStore; + } + async createKey(accountId, networkId) { + const keyPair = key_pair_1.KeyPair.fromRandom('ed25519'); + await this.keyStore.setKey(networkId, accountId, keyPair); + return keyPair.getPublicKey(); + } + async getPublicKey(accountId, networkId) { + const keyPair = await this.keyStore.getKey(networkId, accountId); + return keyPair.getPublicKey(); + } + async signHash(hash, accountId, networkId) { + if (!accountId) { + throw new Error('InMemorySigner requires provided account id'); } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.newAccountId != null && message.hasOwnProperty("newAccountId")) - object.newAccountId = message.newAccountId; - if (message.amount != null && message.hasOwnProperty("amount")) - object.amount = $root.Uint128.toObject(message.amount, options); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - object.publicKey = options.bytes === String ? $util.base64.encode(message.publicKey, 0, message.publicKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.publicKey) : message.publicKey; - return object; - }; - - /** - * Converts this CreateAccountTransaction to JSON. - * @function toJSON - * @memberof CreateAccountTransaction - * @instance - * @returns {Object.} JSON object - */ - CreateAccountTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return CreateAccountTransaction; -})(); - -$root.DeployContractTransaction = (function() { - - /** - * Properties of a DeployContractTransaction. - * @exports IDeployContractTransaction - * @interface IDeployContractTransaction - * @property {number|Long|null} [nonce] DeployContractTransaction nonce - * @property {string|null} [contractId] DeployContractTransaction contractId - * @property {Uint8Array|null} [wasmByteArray] DeployContractTransaction wasmByteArray - */ - - /** - * Constructs a new DeployContractTransaction. - * @exports DeployContractTransaction - * @classdesc Represents a DeployContractTransaction. - * @implements IDeployContractTransaction - * @constructor - * @param {IDeployContractTransaction=} [properties] Properties to set - */ - function DeployContractTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + const keyPair = await this.keyStore.getKey(networkId, accountId); + if (keyPair === null) { + throw new Error(`Key for ${accountId} not found in ${networkId}`); + } + return keyPair.sign(hash); } +} +exports.InMemorySigner = InMemorySigner; - /** - * DeployContractTransaction nonce. - * @member {number|Long} nonce - * @memberof DeployContractTransaction - * @instance - */ - DeployContractTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * DeployContractTransaction contractId. - * @member {string} contractId - * @memberof DeployContractTransaction - * @instance - */ - DeployContractTransaction.prototype.contractId = ""; - - /** - * DeployContractTransaction wasmByteArray. - * @member {Uint8Array} wasmByteArray - * @memberof DeployContractTransaction - * @instance - */ - DeployContractTransaction.prototype.wasmByteArray = $util.newBuffer([]); - - /** - * Creates a new DeployContractTransaction instance using the specified properties. - * @function create - * @memberof DeployContractTransaction - * @static - * @param {IDeployContractTransaction=} [properties] Properties to set - * @returns {DeployContractTransaction} DeployContractTransaction instance - */ - DeployContractTransaction.create = function create(properties) { - return new DeployContractTransaction(properties); - }; - - /** - * Encodes the specified DeployContractTransaction message. Does not implicitly {@link DeployContractTransaction.verify|verify} messages. - * @function encode - * @memberof DeployContractTransaction - * @static - * @param {IDeployContractTransaction} message DeployContractTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployContractTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.contractId != null && message.hasOwnProperty("contractId")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.contractId); - if (message.wasmByteArray != null && message.hasOwnProperty("wasmByteArray")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.wasmByteArray); - return writer; - }; - - /** - * Encodes the specified DeployContractTransaction message, length delimited. Does not implicitly {@link DeployContractTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof DeployContractTransaction - * @static - * @param {IDeployContractTransaction} message DeployContractTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeployContractTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a DeployContractTransaction message from the specified reader or buffer. - * @function decode - * @memberof DeployContractTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {DeployContractTransaction} DeployContractTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployContractTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DeployContractTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.contractId = reader.string(); - break; - case 3: - message.wasmByteArray = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a DeployContractTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof DeployContractTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {DeployContractTransaction} DeployContractTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeployContractTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies a DeployContractTransaction message. - * @function verify - * @memberof DeployContractTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DeployContractTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.contractId != null && message.hasOwnProperty("contractId")) - if (!$util.isString(message.contractId)) - return "contractId: string expected"; - if (message.wasmByteArray != null && message.hasOwnProperty("wasmByteArray")) - if (!(message.wasmByteArray && typeof message.wasmByteArray.length === "number" || $util.isString(message.wasmByteArray))) - return "wasmByteArray: buffer expected"; - return null; - }; - - /** - * Creates a DeployContractTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof DeployContractTransaction - * @static - * @param {Object.} object Plain object - * @returns {DeployContractTransaction} DeployContractTransaction - */ - DeployContractTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.DeployContractTransaction) - return object; - var message = new $root.DeployContractTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.contractId != null) - message.contractId = String(object.contractId); - if (object.wasmByteArray != null) - if (typeof object.wasmByteArray === "string") - $util.base64.decode(object.wasmByteArray, message.wasmByteArray = $util.newBuffer($util.base64.length(object.wasmByteArray)), 0); - else if (object.wasmByteArray.length) - message.wasmByteArray = object.wasmByteArray; - return message; - }; - - /** - * Creates a plain object from a DeployContractTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof DeployContractTransaction - * @static - * @param {DeployContractTransaction} message DeployContractTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DeployContractTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.contractId = ""; - if (options.bytes === String) - object.wasmByteArray = ""; - else { - object.wasmByteArray = []; - if (options.bytes !== Array) - object.wasmByteArray = $util.newBuffer(object.wasmByteArray); - } - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.contractId != null && message.hasOwnProperty("contractId")) - object.contractId = message.contractId; - if (message.wasmByteArray != null && message.hasOwnProperty("wasmByteArray")) - object.wasmByteArray = options.bytes === String ? $util.base64.encode(message.wasmByteArray, 0, message.wasmByteArray.length) : options.bytes === Array ? Array.prototype.slice.call(message.wasmByteArray) : message.wasmByteArray; - return object; - }; - - /** - * Converts this DeployContractTransaction to JSON. - * @function toJSON - * @memberof DeployContractTransaction - * @instance - * @returns {Object.} JSON object - */ - DeployContractTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return DeployContractTransaction; -})(); - -$root.FunctionCallTransaction = (function() { - - /** - * Properties of a FunctionCallTransaction. - * @exports IFunctionCallTransaction - * @interface IFunctionCallTransaction - * @property {number|Long|null} [nonce] FunctionCallTransaction nonce - * @property {string|null} [originator] FunctionCallTransaction originator - * @property {string|null} [contractId] FunctionCallTransaction contractId - * @property {Uint8Array|null} [methodName] FunctionCallTransaction methodName - * @property {Uint8Array|null} [args] FunctionCallTransaction args - * @property {IUint128|null} [amount] FunctionCallTransaction amount - */ - - /** - * Constructs a new FunctionCallTransaction. - * @exports FunctionCallTransaction - * @classdesc Represents a FunctionCallTransaction. - * @implements IFunctionCallTransaction - * @constructor - * @param {IFunctionCallTransaction=} [properties] Properties to set - */ - function FunctionCallTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; +},{"./utils/key_pair":20,"js-sha256":50}],18:[function(require,module,exports){ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const js_sha256_1 = __importDefault(require("js-sha256")); +const serialize_1 = require("./utils/serialize"); +class Enum { + constructor(properties) { + if (Object.keys(properties).length !== 1) { + throw new Error('Enum can only take single value'); + } + Object.keys(properties).map((key) => { + this[key] = properties[key]; + this.enum = key; + }); } +} +class Assignable { + constructor(properties) { + Object.keys(properties).map((key) => { + this[key] = properties[key]; + }); + } +} +class FunctionCallPermission extends Assignable { +} +exports.FunctionCallPermission = FunctionCallPermission; +class FullAccessPermission extends Assignable { +} +exports.FullAccessPermission = FullAccessPermission; +class AccessKeyPermission extends Enum { +} +exports.AccessKeyPermission = AccessKeyPermission; +class AccessKey extends Assignable { +} +exports.AccessKey = AccessKey; +function fullAccessKey() { + return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ fullAccess: new FullAccessPermission({}) }) }); +} +exports.fullAccessKey = fullAccessKey; +function functionCallAccessKey(receiverId, methodNames, allowance) { + return new AccessKey({ nonce: 0, permission: new AccessKeyPermission({ functionCall: new FunctionCallPermission({ receiverId, allowance, methodNames }) }) }); +} +exports.functionCallAccessKey = functionCallAccessKey; +class IAction extends Assignable { +} +exports.IAction = IAction; +class CreateAccount extends IAction { +} +class DeployContract extends IAction { +} +class FunctionCall extends IAction { +} +class Transfer extends IAction { +} +class Stake extends IAction { +} +class AddKey extends IAction { +} +class DeleteKey extends IAction { +} +class DeleteAccount extends IAction { +} +function createAccount() { + return new Action({ createAccount: new CreateAccount({}) }); +} +exports.createAccount = createAccount; +function deployContract(code) { + return new Action({ deployContract: new DeployContract({ code }) }); +} +exports.deployContract = deployContract; +function functionCall(methodName, args, gas, deposit) { + return new Action({ functionCall: new FunctionCall({ methodName, args, gas, deposit }) }); +} +exports.functionCall = functionCall; +function transfer(deposit) { + return new Action({ transfer: new Transfer({ deposit }) }); +} +exports.transfer = transfer; +function stake(stake, publicKey) { + return new Action({ stake: new Stake({ stake, publicKey: new PublicKey(publicKey) }) }); +} +exports.stake = stake; +function addKey(publicKey, accessKey) { + return new Action({ addKey: new AddKey({ publicKey: new PublicKey(publicKey), accessKey }) }); +} +exports.addKey = addKey; +function deleteKey(publicKey) { + return new Action({ deleteKey: new DeleteKey({ publicKey: new PublicKey(publicKey) }) }); +} +exports.deleteKey = deleteKey; +function deleteAccount(beneficiaryId) { + return new Action({ deleteAccount: new DeleteAccount({ beneficiaryId }) }); +} +exports.deleteAccount = deleteAccount; +var KeyType; +(function (KeyType) { + KeyType[KeyType["ED25519"] = 0] = "ED25519"; +})(KeyType || (KeyType = {})); +class PublicKey { + constructor(publicKey) { + this.keyType = KeyType.ED25519; + this.data = serialize_1.base_decode(publicKey); + } +} +class Signature { + constructor(signature) { + this.keyType = KeyType.ED25519; + this.data = signature; + } +} +class Transaction extends Assignable { +} +class SignedTransaction extends Assignable { + encode() { + return serialize_1.serialize(SCHEMA, this); + } +} +exports.SignedTransaction = SignedTransaction; +class Action extends Enum { +} +exports.Action = Action; +const SCHEMA = { + Signature: { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }, + SignedTransaction: { kind: 'struct', fields: [['transaction', Transaction], ['signature', Signature]] }, + Transaction: { + kind: 'struct', fields: [['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['actions', [Action]]] + }, + PublicKey: { + kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] + }, + AccessKey: { kind: 'struct', fields: [ + ['nonce', 'u64'], + ['permission', AccessKeyPermission], + ] }, + AccessKeyPermission: { kind: 'enum', field: 'enum', values: [ + ['functionCall', FunctionCallPermission], + ['fullAccess', FullAccessPermission], + ] }, + FunctionCallPermission: { kind: 'struct', fields: [ + ['allowance', { kind: 'option', type: 'u128' }], + ['receiverId', 'string'], + ['methodNames', ['string']], + ] }, + FullAccessPermission: { kind: 'struct', fields: [] }, + Action: { kind: 'enum', field: 'enum', values: [ + ['createAccount', CreateAccount], + ['deployContract', DeployContract], + ['functionCall', functionCall], + ['transfer', transfer], + ['stake', stake], + ['addKey', addKey], + ['deleteKey', deleteKey], + ['deleteAccount', deleteAccount], + ] }, + CreateAccount: { kind: 'struct', fields: [] }, + DeployContract: { kind: 'struct', fields: [['code', ['u8']]] }, + FunctionCall: { kind: 'struct', fields: [['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128']] }, + Transfer: { kind: 'struct', fields: [['deposit', 'u128']] }, + Stake: { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', PublicKey]] }, + AddKey: { kind: 'struct', fields: [['publicKey', PublicKey], ['accessKey', AccessKey]] }, + DeleteKey: { kind: 'struct', fields: [['publicKey', PublicKey]] }, + DeleteAccount: { kind: 'struct', fields: [['beneficiaryId', 'string']] }, +}; +async function signTransaction(receiverId, nonce, actions, signer, accountId, networkId) { + const publicKey = new PublicKey(await signer.getPublicKey(accountId, networkId)); + const transaction = new Transaction({ signerId: accountId, publicKey, nonce, receiverId, actions }); + const message = serialize_1.serialize(SCHEMA, transaction); + const hash = new Uint8Array(js_sha256_1.default.sha256.array(message)); + const signature = await signer.signHash(hash, accountId, networkId); + const signedTx = new SignedTransaction({ transaction, signature: new Signature(signature.signature) }); + return [hash, signedTx]; +} +exports.signTransaction = signTransaction; - /** - * FunctionCallTransaction nonce. - * @member {number|Long} nonce - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * FunctionCallTransaction originator. - * @member {string} originator - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.originator = ""; - - /** - * FunctionCallTransaction contractId. - * @member {string} contractId - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.contractId = ""; - - /** - * FunctionCallTransaction methodName. - * @member {Uint8Array} methodName - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.methodName = $util.newBuffer([]); - - /** - * FunctionCallTransaction args. - * @member {Uint8Array} args - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.args = $util.newBuffer([]); - - /** - * FunctionCallTransaction amount. - * @member {IUint128|null|undefined} amount - * @memberof FunctionCallTransaction - * @instance - */ - FunctionCallTransaction.prototype.amount = null; - - /** - * Creates a new FunctionCallTransaction instance using the specified properties. - * @function create - * @memberof FunctionCallTransaction - * @static - * @param {IFunctionCallTransaction=} [properties] Properties to set - * @returns {FunctionCallTransaction} FunctionCallTransaction instance - */ - FunctionCallTransaction.create = function create(properties) { - return new FunctionCallTransaction(properties); - }; - - /** - * Encodes the specified FunctionCallTransaction message. Does not implicitly {@link FunctionCallTransaction.verify|verify} messages. - * @function encode - * @memberof FunctionCallTransaction - * @static - * @param {IFunctionCallTransaction} message FunctionCallTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FunctionCallTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.contractId != null && message.hasOwnProperty("contractId")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.contractId); - if (message.methodName != null && message.hasOwnProperty("methodName")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.methodName); - if (message.args != null && message.hasOwnProperty("args")) - writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.args); - if (message.amount != null && message.hasOwnProperty("amount")) - $root.Uint128.encode(message.amount, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - return writer; - }; - - /** - * Encodes the specified FunctionCallTransaction message, length delimited. Does not implicitly {@link FunctionCallTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof FunctionCallTransaction - * @static - * @param {IFunctionCallTransaction} message FunctionCallTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FunctionCallTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a FunctionCallTransaction message from the specified reader or buffer. - * @function decode - * @memberof FunctionCallTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {FunctionCallTransaction} FunctionCallTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FunctionCallTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.FunctionCallTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.contractId = reader.string(); - break; - case 4: - message.methodName = reader.bytes(); - break; - case 5: - message.args = reader.bytes(); - break; - case 6: - message.amount = $root.Uint128.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes a FunctionCallTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof FunctionCallTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {FunctionCallTransaction} FunctionCallTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FunctionCallTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; +},{"./utils/serialize":22,"js-sha256":50}],19:[function(require,module,exports){ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const key_pair = __importStar(require("./key_pair")); +exports.key_pair = key_pair; +const network = __importStar(require("./network")); +exports.network = network; +const serialize = __importStar(require("./serialize")); +exports.serialize = serialize; +const web = __importStar(require("./web")); +exports.web = web; +const key_pair_1 = require("./key_pair"); +exports.KeyPair = key_pair_1.KeyPair; +exports.KeyPairEd25519 = key_pair_1.KeyPairEd25519; - /** - * Verifies a FunctionCallTransaction message. - * @function verify - * @memberof FunctionCallTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - FunctionCallTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.contractId != null && message.hasOwnProperty("contractId")) - if (!$util.isString(message.contractId)) - return "contractId: string expected"; - if (message.methodName != null && message.hasOwnProperty("methodName")) - if (!(message.methodName && typeof message.methodName.length === "number" || $util.isString(message.methodName))) - return "methodName: buffer expected"; - if (message.args != null && message.hasOwnProperty("args")) - if (!(message.args && typeof message.args.length === "number" || $util.isString(message.args))) - return "args: buffer expected"; - if (message.amount != null && message.hasOwnProperty("amount")) { - var error = $root.Uint128.verify(message.amount); - if (error) - return "amount." + error; +},{"./key_pair":20,"./network":21,"./serialize":22,"./web":23}],20:[function(require,module,exports){ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const tweetnacl_1 = __importDefault(require("tweetnacl")); +const serialize_1 = require("./serialize"); +class KeyPair { + static fromRandom(curve) { + switch (curve) { + case 'ed25519': return KeyPairEd25519.fromRandom(); + default: throw new Error(`Unknown curve ${curve}`); } - return null; - }; - - /** - * Creates a FunctionCallTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof FunctionCallTransaction - * @static - * @param {Object.} object Plain object - * @returns {FunctionCallTransaction} FunctionCallTransaction - */ - FunctionCallTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.FunctionCallTransaction) - return object; - var message = new $root.FunctionCallTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.contractId != null) - message.contractId = String(object.contractId); - if (object.methodName != null) - if (typeof object.methodName === "string") - $util.base64.decode(object.methodName, message.methodName = $util.newBuffer($util.base64.length(object.methodName)), 0); - else if (object.methodName.length) - message.methodName = object.methodName; - if (object.args != null) - if (typeof object.args === "string") - $util.base64.decode(object.args, message.args = $util.newBuffer($util.base64.length(object.args)), 0); - else if (object.args.length) - message.args = object.args; - if (object.amount != null) { - if (typeof object.amount !== "object") - throw TypeError(".FunctionCallTransaction.amount: object expected"); - message.amount = $root.Uint128.fromObject(object.amount); + } + static fromString(encodedKey) { + const parts = encodedKey.split(':'); + if (parts.length !== 2) { + throw new Error('Invalid encoded key format, must be :'); } - return message; - }; - - /** - * Creates a plain object from a FunctionCallTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof FunctionCallTransaction - * @static - * @param {FunctionCallTransaction} message FunctionCallTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - FunctionCallTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - object.contractId = ""; - if (options.bytes === String) - object.methodName = ""; - else { - object.methodName = []; - if (options.bytes !== Array) - object.methodName = $util.newBuffer(object.methodName); - } - if (options.bytes === String) - object.args = ""; - else { - object.args = []; - if (options.bytes !== Array) - object.args = $util.newBuffer(object.args); - } - object.amount = null; + switch (parts[0]) { + case 'ed25519': return new KeyPairEd25519(parts[1]); + default: throw new Error(`Unknown curve: ${parts[0]}`); } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.contractId != null && message.hasOwnProperty("contractId")) - object.contractId = message.contractId; - if (message.methodName != null && message.hasOwnProperty("methodName")) - object.methodName = options.bytes === String ? $util.base64.encode(message.methodName, 0, message.methodName.length) : options.bytes === Array ? Array.prototype.slice.call(message.methodName) : message.methodName; - if (message.args != null && message.hasOwnProperty("args")) - object.args = options.bytes === String ? $util.base64.encode(message.args, 0, message.args.length) : options.bytes === Array ? Array.prototype.slice.call(message.args) : message.args; - if (message.amount != null && message.hasOwnProperty("amount")) - object.amount = $root.Uint128.toObject(message.amount, options); - return object; - }; - - /** - * Converts this FunctionCallTransaction to JSON. - * @function toJSON - * @memberof FunctionCallTransaction - * @instance - * @returns {Object.} JSON object - */ - FunctionCallTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return FunctionCallTransaction; -})(); - -$root.SendMoneyTransaction = (function() { - - /** - * Properties of a SendMoneyTransaction. - * @exports ISendMoneyTransaction - * @interface ISendMoneyTransaction - * @property {number|Long|null} [nonce] SendMoneyTransaction nonce - * @property {string|null} [originator] SendMoneyTransaction originator - * @property {string|null} [receiver] SendMoneyTransaction receiver - * @property {IUint128|null} [amount] SendMoneyTransaction amount - */ - - /** - * Constructs a new SendMoneyTransaction. - * @exports SendMoneyTransaction - * @classdesc Represents a SendMoneyTransaction. - * @implements ISendMoneyTransaction - * @constructor - * @param {ISendMoneyTransaction=} [properties] Properties to set - */ - function SendMoneyTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; } - - /** - * SendMoneyTransaction nonce. - * @member {number|Long} nonce - * @memberof SendMoneyTransaction - * @instance - */ - SendMoneyTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * SendMoneyTransaction originator. - * @member {string} originator - * @memberof SendMoneyTransaction - * @instance - */ - SendMoneyTransaction.prototype.originator = ""; - - /** - * SendMoneyTransaction receiver. - * @member {string} receiver - * @memberof SendMoneyTransaction - * @instance - */ - SendMoneyTransaction.prototype.receiver = ""; - +} +exports.KeyPair = KeyPair; +/** + * This class provides key pair functionality for Ed25519 curve: + * generating key pairs, encoding key pairs, signing and verifying. + */ +class KeyPairEd25519 extends KeyPair { /** - * SendMoneyTransaction amount. - * @member {IUint128|null|undefined} amount - * @memberof SendMoneyTransaction - * @instance + * Construct an instance of key pair given a secret key. + * It's generally assumed that these are encoded in base58. + * @param {string} secretKey */ - SendMoneyTransaction.prototype.amount = null; - + constructor(secretKey) { + super(); + const keyPair = tweetnacl_1.default.sign.keyPair.fromSecretKey(serialize_1.base_decode(secretKey)); + this.publicKey = serialize_1.base_encode(keyPair.publicKey); + this.secretKey = secretKey; + } /** - * Creates a new SendMoneyTransaction instance using the specified properties. - * @function create - * @memberof SendMoneyTransaction - * @static - * @param {ISendMoneyTransaction=} [properties] Properties to set - * @returns {SendMoneyTransaction} SendMoneyTransaction instance + * Generate a new random keypair. + * @example + * const keyRandom = KeyPair.fromRandom(); + * keyRandom.publicKey + * // returns [PUBLIC_KEY] + * + * keyRandom.secretKey + * // returns [SECRET_KEY] */ - SendMoneyTransaction.create = function create(properties) { - return new SendMoneyTransaction(properties); - }; + static fromRandom() { + const newKeyPair = tweetnacl_1.default.sign.keyPair(); + return new KeyPairEd25519(serialize_1.base_encode(newKeyPair.secretKey)); + } + sign(message) { + const signature = tweetnacl_1.default.sign.detached(message, serialize_1.base_decode(this.secretKey)); + return { signature, publicKey: this.publicKey }; + } + verify(message, signature) { + return tweetnacl_1.default.sign.detached.verify(message, signature, serialize_1.base_decode(this.publicKey)); + } + toString() { + return `ed25519:${this.secretKey}`; + } + getPublicKey() { + return this.publicKey; + } +} +exports.KeyPairEd25519 = KeyPairEd25519; - /** - * Encodes the specified SendMoneyTransaction message. Does not implicitly {@link SendMoneyTransaction.verify|verify} messages. - * @function encode - * @memberof SendMoneyTransaction - * @static - * @param {ISendMoneyTransaction} message SendMoneyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SendMoneyTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.receiver != null && message.hasOwnProperty("receiver")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.receiver); - if (message.amount != null && message.hasOwnProperty("amount")) - $root.Uint128.encode(message.amount, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - return writer; - }; +},{"./serialize":22,"tweetnacl":61}],21:[function(require,module,exports){ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); - /** - * Encodes the specified SendMoneyTransaction message, length delimited. Does not implicitly {@link SendMoneyTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof SendMoneyTransaction - * @static - * @param {ISendMoneyTransaction} message SendMoneyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SendMoneyTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes a SendMoneyTransaction message from the specified reader or buffer. - * @function decode - * @memberof SendMoneyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {SendMoneyTransaction} SendMoneyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SendMoneyTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.SendMoneyTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.receiver = reader.string(); - break; - case 4: - message.amount = $root.Uint128.decode(reader, reader.uint32()); +},{}],22:[function(require,module,exports){ +(function (Buffer){ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const bs58_1 = __importDefault(require("bs58")); +const bn_js_1 = __importDefault(require("bn.js")); +function base_encode(value) { + if (typeof (value) === 'string') { + value = Buffer.from(value, 'utf8'); + } + return bs58_1.default.encode(Buffer.from(value)); +} +exports.base_encode = base_encode; +function base_decode(value) { + return bs58_1.default.decode(value); +} +exports.base_decode = base_decode; +const INITIAL_LENGTH = 1024; +/// Binary encoder. +class BinaryWriter { + constructor() { + this.buf = Buffer.alloc(INITIAL_LENGTH); + this.length = 0; + } + maybe_resize() { + if (this.buf.length < 16 + this.length) { + this.buf = Buffer.concat([this.buf, Buffer.alloc(INITIAL_LENGTH)]); + } + } + write_u8(value) { + this.maybe_resize(); + this.buf.writeUInt8(value, this.length); + this.length += 1; + } + write_u32(value) { + this.maybe_resize(); + this.buf.writeUInt32LE(value, this.length); + this.length += 4; + } + write_u64(value) { + this.maybe_resize(); + this.write_buffer(Buffer.from(new bn_js_1.default(value).toArray('le', 8))); + } + write_u128(value) { + this.maybe_resize(); + this.write_buffer(Buffer.from(new bn_js_1.default(value).toArray('le', 16))); + } + write_buffer(buffer) { + this.buf = Buffer.concat([this.buf.subarray(0, this.length), buffer, Buffer.alloc(INITIAL_LENGTH)]); + this.length += buffer.length; + } + write_string(str) { + this.maybe_resize(); + const b = Buffer.from(str, 'utf8'); + this.write_u32(b.length); + this.write_buffer(b); + } + write_fixed_array(array) { + this.write_buffer(Buffer.from(array)); + } + write_array(array, fn) { + this.maybe_resize(); + this.write_u32(array.length); + for (const elem of array) { + this.maybe_resize(); + fn(elem); + } + } + toArray() { + return this.buf.subarray(0, this.length); + } +} +exports.BinaryWriter = BinaryWriter; +class BinaryReader { + constructor(buf) { + this.buf = buf; + this.offset = 0; + } + read_u8() { + const value = this.buf.readUInt8(this.offset); + this.offset += 1; + return value; + } + read_u32() { + const value = this.buf.readUInt32LE(this.offset); + this.offset += 4; + return value; + } + read_u64() { + const buf = this.read_buffer(8); + buf.reverse(); + return new bn_js_1.default(`${buf.toString('hex')}`, 16); + } + read_u128() { + const buf = this.read_buffer(16); + return new bn_js_1.default(buf); + } + read_buffer(len) { + const result = this.buf.slice(this.offset, this.offset + len); + this.offset += len; + return result; + } + read_string() { + const len = this.read_u32(); + return this.read_buffer(len).toString('utf8'); + } + read_fixed_array(len) { + return new Uint8Array(this.read_buffer(len)); + } + read_array(fn) { + const len = this.read_u32(); + const result = Array(); + for (let i = 0; i < len; ++i) { + result.push(fn()); + } + return result; + } +} +exports.BinaryReader = BinaryReader; +function serializeField(schema, value, fieldType, writer) { + if (typeof fieldType === 'string') { + writer[`write_${fieldType}`](value); + } + else if (fieldType instanceof Array) { + if (typeof fieldType[0] === 'number') { + writer.write_fixed_array(value); + } + else { + writer.write_array(value, (item) => { serializeField(schema, item, fieldType[0], writer); }); + } + } + else if (fieldType.kind !== undefined) { + switch (fieldType.kind) { + case 'option': { + if (value === null) { + writer.write_u8(0); + } + else { + writer.write_u8(1); + serializeField(schema, value, fieldType.type, writer); + } break; - default: - reader.skipType(tag & 7); + } + default: throw new Error(`FieldType ${fieldType} unrecognized`); + } + } + else { + serializeStruct(schema, value, writer); + } +} +function serializeStruct(schema, obj, writer) { + const className = obj.constructor.name; + if (schema[className] === undefined) { + throw new Error(`Class ${className} is missing in schema`); + } + if (schema[className].kind === 'struct') { + schema[className].fields.map(([fieldName, fieldType]) => { + serializeField(schema, obj[fieldName], fieldType, writer); + }); + } + else if (schema[className].kind === 'enum') { + const name = obj[schema[className].field]; + for (let idx = 0; idx < schema[className].values.length; ++idx) { + const [fieldName, fieldType] = schema[className].values[idx]; + if (fieldName === name) { + writer.write_u8(idx); + serializeField(schema, obj[fieldName], fieldType, writer); break; } } - return message; - }; + } + else { + throw new Error(`Unexpected schema kind: ${schema[className].kind} for ${className}`); + } +} +/// Serialize given object using schema of the form: +/// { class_name -> [ [field_name, field_type], .. ], .. } +function serialize(schema, obj) { + const writer = new BinaryWriter(); + serializeStruct(schema, obj, writer); + return writer.toArray(); +} +exports.serialize = serialize; +function deserializeField(schema, fieldType, reader) { + if (typeof fieldType === 'string') { + return reader[`read_${fieldType}`](); + } + else if (fieldType instanceof Array) { + if (typeof fieldType[0] === 'number') { + return reader.read_fixed_array(fieldType[0]); + } + else { + return reader.read_array(() => deserializeField(schema, fieldType[0], reader)); + } + } + else { + return deserializeStruct(schema, fieldType, reader); + } +} +function deserializeStruct(schema, classType, reader) { + const fields = schema[classType.name].fields.map(([fieldName, fieldType]) => { + return deserializeField(schema, fieldType, reader); + }); + return new classType(...fields); +} +/// Deserializes object from bytes using schema. +function deserialize(schema, classType, buffer) { + const reader = new BinaryReader(buffer); + return deserializeStruct(schema, classType, reader); +} +exports.deserialize = deserialize; + +}).call(this,require("buffer").Buffer) +},{"bn.js":27,"bs58":30,"buffer":31}],23:[function(require,module,exports){ +'use strict'; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const http_errors_1 = __importDefault(require("http-errors")); +const fetch = (typeof window === 'undefined' || window.name === 'nodejs') ? require('node-fetch') : window.fetch; +async function fetchJson(connection, json) { + let url = null; + if (typeof (connection) === 'string') { + url = connection; + } + else { + url = connection.url; + } + const response = await fetch(url, { + method: json ? 'POST' : 'GET', + body: json ? json : undefined, + headers: { 'Content-type': 'application/json; charset=utf-8' } + }); + if (!response.ok) { + throw http_errors_1.default(response.status, await response.text()); + } + return await response.json(); +} +exports.fetchJson = fetchJson; +},{"http-errors":47,"node-fetch":29}],24:[function(require,module,exports){ +'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("./utils"); +const LOGIN_WALLET_URL_SUFFIX = '/login/'; +const LOCAL_STORAGE_KEY_SUFFIX = '_wallet_auth_key'; +const PENDING_ACCESS_KEY_PREFIX = 'pending_key'; // browser storage key for a pending access key (i.e. key has been generated but we are not sure it was added yet) +class WalletAccount { + constructor(near, appKeyPrefix) { + this._networkId = near.config.networkId; + this._walletBaseUrl = near.config.walletUrl; + appKeyPrefix = appKeyPrefix || near.config.contractName || 'default'; + this._authDataKey = appKeyPrefix + LOCAL_STORAGE_KEY_SUFFIX; + this._keyStore = near.connection.signer.keyStore; + this._authData = JSON.parse(window.localStorage.getItem(this._authDataKey) || '{}'); + if (!this.isSignedIn()) { + this._completeSignInWithAccessKey(); + } + } /** - * Decodes a SendMoneyTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof SendMoneyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {SendMoneyTransaction} SendMoneyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing + * Returns true, if this WalletAccount is authorized with the wallet. + * @example + * walletAccount.isSignedIn(); */ - SendMoneyTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - + isSignedIn() { + return !!this._authData.accountId; + } /** - * Verifies a SendMoneyTransaction message. - * @function verify - * @memberof SendMoneyTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not + * Returns authorized Account ID. + * @example + * walletAccount.getAccountId(); */ - SendMoneyTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.receiver != null && message.hasOwnProperty("receiver")) - if (!$util.isString(message.receiver)) - return "receiver: string expected"; - if (message.amount != null && message.hasOwnProperty("amount")) { - var error = $root.Uint128.verify(message.amount); - if (error) - return "amount." + error; - } - return null; - }; - + getAccountId() { + return this._authData.accountId || ''; + } /** - * Creates a SendMoneyTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof SendMoneyTransaction - * @static - * @param {Object.} object Plain object - * @returns {SendMoneyTransaction} SendMoneyTransaction + * Redirects current page to the wallet authentication page. + * @param {string} contractId contract ID of the application + * @param {string} title name of the application + * @param {string} successUrl url to redirect on success + * @param {string} failureUrl url to redirect on failure + * @example + * walletAccount.requestSignIn( + * myContractId, + * title, + * onSuccessHref, + * onFailureHref); */ - SendMoneyTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.SendMoneyTransaction) - return object; - var message = new $root.SendMoneyTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.receiver != null) - message.receiver = String(object.receiver); - if (object.amount != null) { - if (typeof object.amount !== "object") - throw TypeError(".SendMoneyTransaction.amount: object expected"); - message.amount = $root.Uint128.fromObject(object.amount); + async requestSignIn(contractId, title, successUrl, failureUrl) { + if (this.getAccountId() || await this._keyStore.getKey(this._networkId, this.getAccountId())) { + return Promise.resolve(); } - return message; - }; - + const currentUrl = new URL(window.location.href); + const newUrl = new URL(this._walletBaseUrl + LOGIN_WALLET_URL_SUFFIX); + newUrl.searchParams.set('title', title); + newUrl.searchParams.set('contract_id', contractId); + newUrl.searchParams.set('success_url', successUrl || currentUrl.href); + newUrl.searchParams.set('failure_url', failureUrl || currentUrl.href); + newUrl.searchParams.set('app_url', currentUrl.origin); + const accessKey = utils_1.KeyPair.fromRandom('ed25519'); + newUrl.searchParams.set('public_key', accessKey.getPublicKey()); + await this._keyStore.setKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + accessKey.getPublicKey(), accessKey); + window.location.assign(newUrl.toString()); + } /** - * Creates a plain object from a SendMoneyTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof SendMoneyTransaction - * @static - * @param {SendMoneyTransaction} message SendMoneyTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object + * Complete sign in for a given account id and public key. To be invoked by the app when getting a callback from the wallet. */ - SendMoneyTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - object.receiver = ""; - object.amount = null; + async _completeSignInWithAccessKey() { + const currentUrl = new URL(window.location.href); + const publicKey = currentUrl.searchParams.get('public_key') || ''; + const accountId = currentUrl.searchParams.get('account_id') || ''; + if (accountId && publicKey) { + this._authData = { + accountId + }; + window.localStorage.setItem(this._authDataKey, JSON.stringify(this._authData)); + await this._moveKeyFromTempToPermanent(accountId, publicKey); } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.receiver != null && message.hasOwnProperty("receiver")) - object.receiver = message.receiver; - if (message.amount != null && message.hasOwnProperty("amount")) - object.amount = $root.Uint128.toObject(message.amount, options); - return object; - }; - + } + async _moveKeyFromTempToPermanent(accountId, publicKey) { + const keyPair = await this._keyStore.getKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + publicKey); + await this._keyStore.setKey(this._networkId, accountId, keyPair); + await this._keyStore.removeKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + publicKey); + } /** - * Converts this SendMoneyTransaction to JSON. - * @function toJSON - * @memberof SendMoneyTransaction - * @instance - * @returns {Object.} JSON object + * Sign out from the current account + * @example + * walletAccount.signOut(); */ - SendMoneyTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + signOut() { + this._authData = {}; + window.localStorage.removeItem(this._authDataKey); + } +} +exports.WalletAccount = WalletAccount; - return SendMoneyTransaction; -})(); +},{"./utils":19}],25:[function(require,module,exports){ +// base-x encoding / decoding +// Copyright (c) 2018 base-x contributors +// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) +// Distributed under the MIT software license, see the accompanying +// file LICENSE or http://www.opensource.org/licenses/mit-license.php. -$root.StakeTransaction = (function() { +const Buffer = require('safe-buffer').Buffer - /** - * Properties of a StakeTransaction. - * @exports IStakeTransaction - * @interface IStakeTransaction - * @property {number|Long|null} [nonce] StakeTransaction nonce - * @property {string|null} [originator] StakeTransaction originator - * @property {IUint128|null} [amount] StakeTransaction amount - * @property {string|null} [publicKey] StakeTransaction publicKey - * @property {string|null} [blsPublicKey] StakeTransaction blsPublicKey - */ +module.exports = function base (ALPHABET) { + if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long') - /** - * Constructs a new StakeTransaction. - * @exports StakeTransaction - * @classdesc Represents a StakeTransaction. - * @implements IStakeTransaction - * @constructor - * @param {IStakeTransaction=} [properties] Properties to set - */ - function StakeTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + const BASE_MAP = new Uint8Array(256) + BASE_MAP.fill(255) - /** - * StakeTransaction nonce. - * @member {number|Long} nonce - * @memberof StakeTransaction - * @instance - */ - StakeTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + for (let i = 0; i < ALPHABET.length; i++) { + const x = ALPHABET.charAt(i) + const xc = x.charCodeAt(0) - /** - * StakeTransaction originator. - * @member {string} originator - * @memberof StakeTransaction - * @instance - */ - StakeTransaction.prototype.originator = ""; + if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') + BASE_MAP[xc] = i + } - /** - * StakeTransaction amount. - * @member {IUint128|null|undefined} amount - * @memberof StakeTransaction - * @instance - */ - StakeTransaction.prototype.amount = null; + const BASE = ALPHABET.length + const LEADER = ALPHABET.charAt(0) + const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up + const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - /** - * StakeTransaction publicKey. - * @member {string} publicKey - * @memberof StakeTransaction - * @instance - */ - StakeTransaction.prototype.publicKey = ""; + function encode (source) { + if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') + if (source.length === 0) return '' - /** - * StakeTransaction blsPublicKey. - * @member {string} blsPublicKey - * @memberof StakeTransaction - * @instance - */ - StakeTransaction.prototype.blsPublicKey = ""; + // Skip & count leading zeroes. + let zeroes = 0 + let length = 0 + let pbegin = 0 + const pend = source.length - /** - * Creates a new StakeTransaction instance using the specified properties. - * @function create - * @memberof StakeTransaction - * @static - * @param {IStakeTransaction=} [properties] Properties to set - * @returns {StakeTransaction} StakeTransaction instance - */ - StakeTransaction.create = function create(properties) { - return new StakeTransaction(properties); - }; - - /** - * Encodes the specified StakeTransaction message. Does not implicitly {@link StakeTransaction.verify|verify} messages. - * @function encode - * @memberof StakeTransaction - * @static - * @param {IStakeTransaction} message StakeTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - StakeTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.amount != null && message.hasOwnProperty("amount")) - $root.Uint128.encode(message.amount, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - writer.uint32(/* id 4, wireType 2 =*/34).string(message.publicKey); - if (message.blsPublicKey != null && message.hasOwnProperty("blsPublicKey")) - writer.uint32(/* id 5, wireType 2 =*/42).string(message.blsPublicKey); - return writer; - }; + while (pbegin !== pend && source[pbegin] === 0) { + pbegin++ + zeroes++ + } - /** - * Encodes the specified StakeTransaction message, length delimited. Does not implicitly {@link StakeTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof StakeTransaction - * @static - * @param {IStakeTransaction} message StakeTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - StakeTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // Allocate enough space in big-endian base58 representation. + const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 + const b58 = new Uint8Array(size) - /** - * Decodes a StakeTransaction message from the specified reader or buffer. - * @function decode - * @memberof StakeTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {StakeTransaction} StakeTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - StakeTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.StakeTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.amount = $root.Uint128.decode(reader, reader.uint32()); - break; - case 4: - message.publicKey = reader.string(); - break; - case 5: - message.blsPublicKey = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + // Process the bytes. + while (pbegin !== pend) { + let carry = source[pbegin] - /** - * Decodes a StakeTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof StakeTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {StakeTransaction} StakeTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - StakeTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + // Apply "b58 = b58 * 256 + ch". + let i = 0 + for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { + carry += (256 * b58[it]) >>> 0 + b58[it] = (carry % BASE) >>> 0 + carry = (carry / BASE) >>> 0 + } - /** - * Verifies a StakeTransaction message. - * @function verify - * @memberof StakeTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - StakeTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.amount != null && message.hasOwnProperty("amount")) { - var error = $root.Uint128.verify(message.amount); - if (error) - return "amount." + error; - } - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - if (!$util.isString(message.publicKey)) - return "publicKey: string expected"; - if (message.blsPublicKey != null && message.hasOwnProperty("blsPublicKey")) - if (!$util.isString(message.blsPublicKey)) - return "blsPublicKey: string expected"; - return null; - }; + if (carry !== 0) throw new Error('Non-zero carry') + length = i + pbegin++ + } - /** - * Creates a StakeTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof StakeTransaction - * @static - * @param {Object.} object Plain object - * @returns {StakeTransaction} StakeTransaction - */ - StakeTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.StakeTransaction) - return object; - var message = new $root.StakeTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.amount != null) { - if (typeof object.amount !== "object") - throw TypeError(".StakeTransaction.amount: object expected"); - message.amount = $root.Uint128.fromObject(object.amount); - } - if (object.publicKey != null) - message.publicKey = String(object.publicKey); - if (object.blsPublicKey != null) - message.blsPublicKey = String(object.blsPublicKey); - return message; - }; + // Skip leading zeroes in base58 result. + let it = size - length + while (it !== size && b58[it] === 0) { + it++ + } - /** - * Creates a plain object from a StakeTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof StakeTransaction - * @static - * @param {StakeTransaction} message StakeTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - StakeTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - object.amount = null; - object.publicKey = ""; - object.blsPublicKey = ""; - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.amount != null && message.hasOwnProperty("amount")) - object.amount = $root.Uint128.toObject(message.amount, options); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - object.publicKey = message.publicKey; - if (message.blsPublicKey != null && message.hasOwnProperty("blsPublicKey")) - object.blsPublicKey = message.blsPublicKey; - return object; - }; + // Translate the result into a string. + let str = LEADER.repeat(zeroes) + for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - /** - * Converts this StakeTransaction to JSON. - * @function toJSON - * @memberof StakeTransaction - * @instance - * @returns {Object.} JSON object - */ - StakeTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + return str + } - return StakeTransaction; -})(); + function decodeUnsafe (source) { + if (typeof source !== 'string') throw new TypeError('Expected String') + if (source.length === 0) return Buffer.alloc(0) -$root.SwapKeyTransaction = (function() { + let psz = 0 - /** - * Properties of a SwapKeyTransaction. - * @exports ISwapKeyTransaction - * @interface ISwapKeyTransaction - * @property {number|Long|null} [nonce] SwapKeyTransaction nonce - * @property {string|null} [originator] SwapKeyTransaction originator - * @property {Uint8Array|null} [curKey] SwapKeyTransaction curKey - * @property {Uint8Array|null} [newKey] SwapKeyTransaction newKey - */ + // Skip leading spaces. + if (source[psz] === ' ') return - /** - * Constructs a new SwapKeyTransaction. - * @exports SwapKeyTransaction - * @classdesc Represents a SwapKeyTransaction. - * @implements ISwapKeyTransaction - * @constructor - * @param {ISwapKeyTransaction=} [properties] Properties to set - */ - function SwapKeyTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + // Skip and count leading '1's. + let zeroes = 0 + let length = 0 + while (source[psz] === LEADER) { + zeroes++ + psz++ } - /** - * SwapKeyTransaction nonce. - * @member {number|Long} nonce - * @memberof SwapKeyTransaction - * @instance - */ - SwapKeyTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + // Allocate enough space in big-endian base256 representation. + const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. + const b256 = new Uint8Array(size) - /** - * SwapKeyTransaction originator. - * @member {string} originator - * @memberof SwapKeyTransaction - * @instance - */ - SwapKeyTransaction.prototype.originator = ""; + // Process the characters. + while (source[psz]) { + // Decode character + let carry = BASE_MAP[source.charCodeAt(psz)] - /** - * SwapKeyTransaction curKey. - * @member {Uint8Array} curKey - * @memberof SwapKeyTransaction - * @instance - */ - SwapKeyTransaction.prototype.curKey = $util.newBuffer([]); + // Invalid character + if (carry === 255) return - /** - * SwapKeyTransaction newKey. - * @member {Uint8Array} newKey - * @memberof SwapKeyTransaction - * @instance - */ - SwapKeyTransaction.prototype.newKey = $util.newBuffer([]); + let i = 0 + for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { + carry += (BASE * b256[it]) >>> 0 + b256[it] = (carry % 256) >>> 0 + carry = (carry / 256) >>> 0 + } - /** - * Creates a new SwapKeyTransaction instance using the specified properties. - * @function create - * @memberof SwapKeyTransaction - * @static - * @param {ISwapKeyTransaction=} [properties] Properties to set - * @returns {SwapKeyTransaction} SwapKeyTransaction instance - */ - SwapKeyTransaction.create = function create(properties) { - return new SwapKeyTransaction(properties); - }; + if (carry !== 0) throw new Error('Non-zero carry') + length = i + psz++ + } - /** - * Encodes the specified SwapKeyTransaction message. Does not implicitly {@link SwapKeyTransaction.verify|verify} messages. - * @function encode - * @memberof SwapKeyTransaction - * @static - * @param {ISwapKeyTransaction} message SwapKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SwapKeyTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.curKey != null && message.hasOwnProperty("curKey")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.curKey); - if (message.newKey != null && message.hasOwnProperty("newKey")) - writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.newKey); - return writer; - }; + // Skip trailing spaces. + if (source[psz] === ' ') return - /** - * Encodes the specified SwapKeyTransaction message, length delimited. Does not implicitly {@link SwapKeyTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof SwapKeyTransaction - * @static - * @param {ISwapKeyTransaction} message SwapKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SwapKeyTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // Skip leading zeroes in b256. + let it = size - length + while (it !== size && b256[it] === 0) { + it++ + } - /** - * Decodes a SwapKeyTransaction message from the specified reader or buffer. - * @function decode - * @memberof SwapKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {SwapKeyTransaction} SwapKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SwapKeyTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.SwapKeyTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.curKey = reader.bytes(); - break; - case 4: - message.newKey = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + const vch = Buffer.allocUnsafe(zeroes + (size - it)) + vch.fill(0x00, 0, zeroes) - /** - * Decodes a SwapKeyTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof SwapKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {SwapKeyTransaction} SwapKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SwapKeyTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + let j = zeroes + while (it !== size) { + vch[j++] = b256[it++] + } - /** - * Verifies a SwapKeyTransaction message. - * @function verify - * @memberof SwapKeyTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - SwapKeyTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.curKey != null && message.hasOwnProperty("curKey")) - if (!(message.curKey && typeof message.curKey.length === "number" || $util.isString(message.curKey))) - return "curKey: buffer expected"; - if (message.newKey != null && message.hasOwnProperty("newKey")) - if (!(message.newKey && typeof message.newKey.length === "number" || $util.isString(message.newKey))) - return "newKey: buffer expected"; - return null; - }; + return vch + } - /** - * Creates a SwapKeyTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof SwapKeyTransaction - * @static - * @param {Object.} object Plain object - * @returns {SwapKeyTransaction} SwapKeyTransaction - */ - SwapKeyTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.SwapKeyTransaction) - return object; - var message = new $root.SwapKeyTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.curKey != null) - if (typeof object.curKey === "string") - $util.base64.decode(object.curKey, message.curKey = $util.newBuffer($util.base64.length(object.curKey)), 0); - else if (object.curKey.length) - message.curKey = object.curKey; - if (object.newKey != null) - if (typeof object.newKey === "string") - $util.base64.decode(object.newKey, message.newKey = $util.newBuffer($util.base64.length(object.newKey)), 0); - else if (object.newKey.length) - message.newKey = object.newKey; - return message; - }; + function decode (string) { + const buffer = decodeUnsafe(string) + if (buffer) return buffer - /** - * Creates a plain object from a SwapKeyTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof SwapKeyTransaction - * @static - * @param {SwapKeyTransaction} message SwapKeyTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - SwapKeyTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - if (options.bytes === String) - object.curKey = ""; - else { - object.curKey = []; - if (options.bytes !== Array) - object.curKey = $util.newBuffer(object.curKey); - } - if (options.bytes === String) - object.newKey = ""; - else { - object.newKey = []; - if (options.bytes !== Array) - object.newKey = $util.newBuffer(object.newKey); - } - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.curKey != null && message.hasOwnProperty("curKey")) - object.curKey = options.bytes === String ? $util.base64.encode(message.curKey, 0, message.curKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.curKey) : message.curKey; - if (message.newKey != null && message.hasOwnProperty("newKey")) - object.newKey = options.bytes === String ? $util.base64.encode(message.newKey, 0, message.newKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.newKey) : message.newKey; - return object; - }; + throw new Error('Non-base' + BASE + ' character') + } - /** - * Converts this SwapKeyTransaction to JSON. - * @function toJSON - * @memberof SwapKeyTransaction - * @instance - * @returns {Object.} JSON object - */ - SwapKeyTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + return { + encode: encode, + decodeUnsafe: decodeUnsafe, + decode: decode + } +} - return SwapKeyTransaction; -})(); +},{"safe-buffer":56}],26:[function(require,module,exports){ +'use strict' -$root.AddKeyTransaction = (function() { +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray - /** - * Properties of an AddKeyTransaction. - * @exports IAddKeyTransaction - * @interface IAddKeyTransaction - * @property {number|Long|null} [nonce] AddKeyTransaction nonce - * @property {string|null} [originator] AddKeyTransaction originator - * @property {Uint8Array|null} [newKey] AddKeyTransaction newKey - * @property {IAccessKey|null} [accessKey] AddKeyTransaction accessKey - */ +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - /** - * Constructs a new AddKeyTransaction. - * @exports AddKeyTransaction - * @classdesc Represents an AddKeyTransaction. - * @implements IAddKeyTransaction - * @constructor - * @param {IAddKeyTransaction=} [properties] Properties to set - */ - function AddKeyTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} - /** - * AddKeyTransaction nonce. - * @member {number|Long} nonce - * @memberof AddKeyTransaction - * @instance - */ - AddKeyTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; +// Support decoding URL-safe base64 strings, as Node.js does. +// See: https://en.wikipedia.org/wiki/Base64#URL_applications +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 - /** - * AddKeyTransaction originator. - * @member {string} originator - * @memberof AddKeyTransaction - * @instance - */ - AddKeyTransaction.prototype.originator = ""; +function getLens (b64) { + var len = b64.length - /** - * AddKeyTransaction newKey. - * @member {Uint8Array} newKey - * @memberof AddKeyTransaction - * @instance - */ - AddKeyTransaction.prototype.newKey = $util.newBuffer([]); + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } - /** - * AddKeyTransaction accessKey. - * @member {IAccessKey|null|undefined} accessKey - * @memberof AddKeyTransaction - * @instance - */ - AddKeyTransaction.prototype.accessKey = null; + // Trim off extra bytes after placeholder bytes are found + // See: https://github.com/beatgammit/base64-js/issues/42 + var validLen = b64.indexOf('=') + if (validLen === -1) validLen = len - /** - * Creates a new AddKeyTransaction instance using the specified properties. - * @function create - * @memberof AddKeyTransaction - * @static - * @param {IAddKeyTransaction=} [properties] Properties to set - * @returns {AddKeyTransaction} AddKeyTransaction instance - */ - AddKeyTransaction.create = function create(properties) { - return new AddKeyTransaction(properties); - }; + var placeHoldersLen = validLen === len + ? 0 + : 4 - (validLen % 4) - /** - * Encodes the specified AddKeyTransaction message. Does not implicitly {@link AddKeyTransaction.verify|verify} messages. - * @function encode - * @memberof AddKeyTransaction - * @static - * @param {IAddKeyTransaction} message AddKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AddKeyTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.newKey != null && message.hasOwnProperty("newKey")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.newKey); - if (message.accessKey != null && message.hasOwnProperty("accessKey")) - $root.AccessKey.encode(message.accessKey, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - return writer; - }; + return [validLen, placeHoldersLen] +} - /** - * Encodes the specified AddKeyTransaction message, length delimited. Does not implicitly {@link AddKeyTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof AddKeyTransaction - * @static - * @param {IAddKeyTransaction} message AddKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AddKeyTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; +// base64 is 4/3 + up to two characters of the original data +function byteLength (b64) { + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} - /** - * Decodes an AddKeyTransaction message from the specified reader or buffer. - * @function decode - * @memberof AddKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {AddKeyTransaction} AddKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AddKeyTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.AddKeyTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.newKey = reader.bytes(); - break; - case 4: - message.accessKey = $root.AccessKey.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; +function _byteLength (b64, validLen, placeHoldersLen) { + return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen +} - /** - * Decodes an AddKeyTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof AddKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {AddKeyTransaction} AddKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AddKeyTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an AddKeyTransaction message. - * @function verify - * @memberof AddKeyTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - AddKeyTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.newKey != null && message.hasOwnProperty("newKey")) - if (!(message.newKey && typeof message.newKey.length === "number" || $util.isString(message.newKey))) - return "newKey: buffer expected"; - if (message.accessKey != null && message.hasOwnProperty("accessKey")) { - var error = $root.AccessKey.verify(message.accessKey); - if (error) - return "accessKey." + error; - } - return null; - }; - - /** - * Creates an AddKeyTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof AddKeyTransaction - * @static - * @param {Object.} object Plain object - * @returns {AddKeyTransaction} AddKeyTransaction - */ - AddKeyTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.AddKeyTransaction) - return object; - var message = new $root.AddKeyTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.newKey != null) - if (typeof object.newKey === "string") - $util.base64.decode(object.newKey, message.newKey = $util.newBuffer($util.base64.length(object.newKey)), 0); - else if (object.newKey.length) - message.newKey = object.newKey; - if (object.accessKey != null) { - if (typeof object.accessKey !== "object") - throw TypeError(".AddKeyTransaction.accessKey: object expected"); - message.accessKey = $root.AccessKey.fromObject(object.accessKey); - } - return message; - }; +function toByteArray (b64) { + var tmp + var lens = getLens(b64) + var validLen = lens[0] + var placeHoldersLen = lens[1] - /** - * Creates a plain object from an AddKeyTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof AddKeyTransaction - * @static - * @param {AddKeyTransaction} message AddKeyTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - AddKeyTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - if (options.bytes === String) - object.newKey = ""; - else { - object.newKey = []; - if (options.bytes !== Array) - object.newKey = $util.newBuffer(object.newKey); - } - object.accessKey = null; - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.newKey != null && message.hasOwnProperty("newKey")) - object.newKey = options.bytes === String ? $util.base64.encode(message.newKey, 0, message.newKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.newKey) : message.newKey; - if (message.accessKey != null && message.hasOwnProperty("accessKey")) - object.accessKey = $root.AccessKey.toObject(message.accessKey, options); - return object; - }; + var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - /** - * Converts this AddKeyTransaction to JSON. - * @function toJSON - * @memberof AddKeyTransaction - * @instance - * @returns {Object.} JSON object - */ - AddKeyTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + var curByte = 0 - return AddKeyTransaction; -})(); + // if there are placeholders, only get up to the last complete 4 chars + var len = placeHoldersLen > 0 + ? validLen - 4 + : validLen -$root.DeleteKeyTransaction = (function() { + for (var i = 0; i < len; i += 4) { + tmp = + (revLookup[b64.charCodeAt(i)] << 18) | + (revLookup[b64.charCodeAt(i + 1)] << 12) | + (revLookup[b64.charCodeAt(i + 2)] << 6) | + revLookup[b64.charCodeAt(i + 3)] + arr[curByte++] = (tmp >> 16) & 0xFF + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } - /** - * Properties of a DeleteKeyTransaction. - * @exports IDeleteKeyTransaction - * @interface IDeleteKeyTransaction - * @property {number|Long|null} [nonce] DeleteKeyTransaction nonce - * @property {string|null} [originator] DeleteKeyTransaction originator - * @property {Uint8Array|null} [curKey] DeleteKeyTransaction curKey - */ + if (placeHoldersLen === 2) { + tmp = + (revLookup[b64.charCodeAt(i)] << 2) | + (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[curByte++] = tmp & 0xFF + } - /** - * Constructs a new DeleteKeyTransaction. - * @exports DeleteKeyTransaction - * @classdesc Represents a DeleteKeyTransaction. - * @implements IDeleteKeyTransaction - * @constructor - * @param {IDeleteKeyTransaction=} [properties] Properties to set - */ - function DeleteKeyTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + if (placeHoldersLen === 1) { + tmp = + (revLookup[b64.charCodeAt(i)] << 10) | + (revLookup[b64.charCodeAt(i + 1)] << 4) | + (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[curByte++] = (tmp >> 8) & 0xFF + arr[curByte++] = tmp & 0xFF + } - /** - * DeleteKeyTransaction nonce. - * @member {number|Long} nonce - * @memberof DeleteKeyTransaction - * @instance - */ - DeleteKeyTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + return arr +} - /** - * DeleteKeyTransaction originator. - * @member {string} originator - * @memberof DeleteKeyTransaction - * @instance - */ - DeleteKeyTransaction.prototype.originator = ""; +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + + lookup[num >> 12 & 0x3F] + + lookup[num >> 6 & 0x3F] + + lookup[num & 0x3F] +} - /** - * DeleteKeyTransaction curKey. - * @member {Uint8Array} curKey - * @memberof DeleteKeyTransaction - * @instance - */ - DeleteKeyTransaction.prototype.curKey = $util.newBuffer([]); +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = + ((uint8[i] << 16) & 0xFF0000) + + ((uint8[i + 1] << 8) & 0xFF00) + + (uint8[i + 2] & 0xFF) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} - /** - * Creates a new DeleteKeyTransaction instance using the specified properties. - * @function create - * @memberof DeleteKeyTransaction - * @static - * @param {IDeleteKeyTransaction=} [properties] Properties to set - * @returns {DeleteKeyTransaction} DeleteKeyTransaction instance - */ - DeleteKeyTransaction.create = function create(properties) { - return new DeleteKeyTransaction(properties); - }; +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 - /** - * Encodes the specified DeleteKeyTransaction message. Does not implicitly {@link DeleteKeyTransaction.verify|verify} messages. - * @function encode - * @memberof DeleteKeyTransaction - * @static - * @param {IDeleteKeyTransaction} message DeleteKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeleteKeyTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originator != null && message.hasOwnProperty("originator")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originator); - if (message.curKey != null && message.hasOwnProperty("curKey")) - writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.curKey); - return writer; - }; + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk( + uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) + )) + } - /** - * Encodes the specified DeleteKeyTransaction message, length delimited. Does not implicitly {@link DeleteKeyTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof DeleteKeyTransaction - * @static - * @param {IDeleteKeyTransaction} message DeleteKeyTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeleteKeyTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + parts.push( + lookup[tmp >> 2] + + lookup[(tmp << 4) & 0x3F] + + '==' + ) + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + uint8[len - 1] + parts.push( + lookup[tmp >> 10] + + lookup[(tmp >> 4) & 0x3F] + + lookup[(tmp << 2) & 0x3F] + + '=' + ) + } - /** - * Decodes a DeleteKeyTransaction message from the specified reader or buffer. - * @function decode - * @memberof DeleteKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {DeleteKeyTransaction} DeleteKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeleteKeyTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DeleteKeyTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originator = reader.string(); - break; - case 3: - message.curKey = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + return parts.join('') +} - /** - * Decodes a DeleteKeyTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof DeleteKeyTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {DeleteKeyTransaction} DeleteKeyTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeleteKeyTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; +},{}],27:[function(require,module,exports){ +(function (module, exports) { + 'use strict'; - /** - * Verifies a DeleteKeyTransaction message. - * @function verify - * @memberof DeleteKeyTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DeleteKeyTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originator != null && message.hasOwnProperty("originator")) - if (!$util.isString(message.originator)) - return "originator: string expected"; - if (message.curKey != null && message.hasOwnProperty("curKey")) - if (!(message.curKey && typeof message.curKey.length === "number" || $util.isString(message.curKey))) - return "curKey: buffer expected"; - return null; - }; + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } - /** - * Creates a DeleteKeyTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof DeleteKeyTransaction - * @static - * @param {Object.} object Plain object - * @returns {DeleteKeyTransaction} DeleteKeyTransaction - */ - DeleteKeyTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.DeleteKeyTransaction) - return object; - var message = new $root.DeleteKeyTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originator != null) - message.originator = String(object.originator); - if (object.curKey != null) - if (typeof object.curKey === "string") - $util.base64.decode(object.curKey, message.curKey = $util.newBuffer($util.base64.length(object.curKey)), 0); - else if (object.curKey.length) - message.curKey = object.curKey; - return message; - }; + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } - /** - * Creates a plain object from a DeleteKeyTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof DeleteKeyTransaction - * @static - * @param {DeleteKeyTransaction} message DeleteKeyTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DeleteKeyTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originator = ""; - if (options.bytes === String) - object.curKey = ""; - else { - object.curKey = []; - if (options.bytes !== Array) - object.curKey = $util.newBuffer(object.curKey); - } - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originator != null && message.hasOwnProperty("originator")) - object.originator = message.originator; - if (message.curKey != null && message.hasOwnProperty("curKey")) - object.curKey = options.bytes === String ? $util.base64.encode(message.curKey, 0, message.curKey.length) : options.bytes === Array ? Array.prototype.slice.call(message.curKey) : message.curKey; - return object; - }; + // BN - /** - * Converts this DeleteKeyTransaction to JSON. - * @function toJSON - * @memberof DeleteKeyTransaction - * @instance - * @returns {Object.} JSON object - */ - DeleteKeyTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } - return DeleteKeyTransaction; -})(); + this.negative = 0; + this.words = null; + this.length = 0; -$root.DeleteAccountTransaction = (function() { + // Reduction context + this.red = null; - /** - * Properties of a DeleteAccountTransaction. - * @exports IDeleteAccountTransaction - * @interface IDeleteAccountTransaction - * @property {number|Long|null} [nonce] DeleteAccountTransaction nonce - * @property {string|null} [originatorId] DeleteAccountTransaction originatorId - * @property {string|null} [receiverId] DeleteAccountTransaction receiverId - */ + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } - /** - * Constructs a new DeleteAccountTransaction. - * @exports DeleteAccountTransaction - * @classdesc Represents a DeleteAccountTransaction. - * @implements IDeleteAccountTransaction - * @constructor - * @param {IDeleteAccountTransaction=} [properties] Properties to set - */ - function DeleteAccountTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + this._init(number || 0, base || 10, endian || 'be'); } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } - /** - * DeleteAccountTransaction nonce. - * @member {number|Long} nonce - * @memberof DeleteAccountTransaction - * @instance - */ - DeleteAccountTransaction.prototype.nonce = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + BN.BN = BN; + BN.wordSize = 26; - /** - * DeleteAccountTransaction originatorId. - * @member {string} originatorId - * @memberof DeleteAccountTransaction - * @instance - */ - DeleteAccountTransaction.prototype.originatorId = ""; + var Buffer; + try { + Buffer = require('buffer').Buffer; + } catch (e) { + } - /** - * DeleteAccountTransaction receiverId. - * @member {string} receiverId - * @memberof DeleteAccountTransaction - * @instance - */ - DeleteAccountTransaction.prototype.receiverId = ""; + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } - /** - * Creates a new DeleteAccountTransaction instance using the specified properties. - * @function create - * @memberof DeleteAccountTransaction - * @static - * @param {IDeleteAccountTransaction=} [properties] Properties to set - * @returns {DeleteAccountTransaction} DeleteAccountTransaction instance - */ - DeleteAccountTransaction.create = function create(properties) { - return new DeleteAccountTransaction(properties); - }; + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; - /** - * Encodes the specified DeleteAccountTransaction message. Does not implicitly {@link DeleteAccountTransaction.verify|verify} messages. - * @function encode - * @memberof DeleteAccountTransaction - * @static - * @param {IDeleteAccountTransaction} message DeleteAccountTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeleteAccountTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.nonce != null && message.hasOwnProperty("nonce")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.nonce); - if (message.originatorId != null && message.hasOwnProperty("originatorId")) - writer.uint32(/* id 2, wireType 2 =*/18).string(message.originatorId); - if (message.receiverId != null && message.hasOwnProperty("receiverId")) - writer.uint32(/* id 3, wireType 2 =*/26).string(message.receiverId); - return writer; - }; + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; - /** - * Encodes the specified DeleteAccountTransaction message, length delimited. Does not implicitly {@link DeleteAccountTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof DeleteAccountTransaction - * @static - * @param {IDeleteAccountTransaction} message DeleteAccountTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DeleteAccountTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; - /** - * Decodes a DeleteAccountTransaction message from the specified reader or buffer. - * @function decode - * @memberof DeleteAccountTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {DeleteAccountTransaction} DeleteAccountTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeleteAccountTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.DeleteAccountTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.nonce = reader.uint64(); - break; - case 2: - message.originatorId = reader.string(); - break; - case 3: - message.receiverId = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } - /** - * Decodes a DeleteAccountTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof DeleteAccountTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {DeleteAccountTransaction} DeleteAccountTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DeleteAccountTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } - /** - * Verifies a DeleteAccountTransaction message. - * @function verify - * @memberof DeleteAccountTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DeleteAccountTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (!$util.isInteger(message.nonce) && !(message.nonce && $util.isInteger(message.nonce.low) && $util.isInteger(message.nonce.high))) - return "nonce: integer|Long expected"; - if (message.originatorId != null && message.hasOwnProperty("originatorId")) - if (!$util.isString(message.originatorId)) - return "originatorId: string expected"; - if (message.receiverId != null && message.hasOwnProperty("receiverId")) - if (!$util.isString(message.receiverId)) - return "receiverId: string expected"; - return null; - }; + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); - /** - * Creates a DeleteAccountTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof DeleteAccountTransaction - * @static - * @param {Object.} object Plain object - * @returns {DeleteAccountTransaction} DeleteAccountTransaction - */ - DeleteAccountTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.DeleteAccountTransaction) - return object; - var message = new $root.DeleteAccountTransaction(); - if (object.nonce != null) - if ($util.Long) - (message.nonce = $util.Long.fromValue(object.nonce)).unsigned = true; - else if (typeof object.nonce === "string") - message.nonce = parseInt(object.nonce, 10); - else if (typeof object.nonce === "number") - message.nonce = object.nonce; - else if (typeof object.nonce === "object") - message.nonce = new $util.LongBits(object.nonce.low >>> 0, object.nonce.high >>> 0).toNumber(true); - if (object.originatorId != null) - message.originatorId = String(object.originatorId); - if (object.receiverId != null) - message.receiverId = String(object.receiverId); - return message; - }; + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + } - /** - * Creates a plain object from a DeleteAccountTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof DeleteAccountTransaction - * @static - * @param {DeleteAccountTransaction} message DeleteAccountTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DeleteAccountTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.nonce = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.nonce = options.longs === String ? "0" : 0; - object.originatorId = ""; - object.receiverId = ""; - } - if (message.nonce != null && message.hasOwnProperty("nonce")) - if (typeof message.nonce === "number") - object.nonce = options.longs === String ? String(message.nonce) : message.nonce; - else - object.nonce = options.longs === String ? $util.Long.prototype.toString.call(message.nonce) : options.longs === Number ? new $util.LongBits(message.nonce.low >>> 0, message.nonce.high >>> 0).toNumber(true) : message.nonce; - if (message.originatorId != null && message.hasOwnProperty("originatorId")) - object.originatorId = message.originatorId; - if (message.receiverId != null && message.hasOwnProperty("receiverId")) - object.receiverId = message.receiverId; - return object; - }; + if (base === 16) { + this._parseHex(number, start); + } else { + this._parseBase(number, base, start); + } - /** - * Converts this DeleteAccountTransaction to JSON. - * @function toJSON - * @memberof DeleteAccountTransaction - * @instance - * @returns {Object.} JSON object - */ - DeleteAccountTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + if (number[0] === '-') { + this.negative = 1; + } - return DeleteAccountTransaction; -})(); + this.strip(); -$root.SignedTransaction = (function() { + if (endian !== 'le') return; - /** - * Properties of a SignedTransaction. - * @exports ISignedTransaction - * @interface ISignedTransaction - * @property {Uint8Array|null} [signature] SignedTransaction signature - * @property {google.protobuf.IBytesValue|null} [publicKey] SignedTransaction publicKey - * @property {ICreateAccountTransaction|null} [createAccount] SignedTransaction createAccount - * @property {IDeployContractTransaction|null} [deployContract] SignedTransaction deployContract - * @property {IFunctionCallTransaction|null} [functionCall] SignedTransaction functionCall - * @property {ISendMoneyTransaction|null} [sendMoney] SignedTransaction sendMoney - * @property {IStakeTransaction|null} [stake] SignedTransaction stake - * @property {ISwapKeyTransaction|null} [swapKey] SignedTransaction swapKey - * @property {IAddKeyTransaction|null} [addKey] SignedTransaction addKey - * @property {IDeleteKeyTransaction|null} [deleteKey] SignedTransaction deleteKey - * @property {IDeleteAccountTransaction|null} [deleteAccount] SignedTransaction deleteAccount - */ + this._initArray(this.toArray(), base, endian); + }; - /** - * Constructs a new SignedTransaction. - * @exports SignedTransaction - * @classdesc Represents a SignedTransaction. - * @implements ISignedTransaction - * @constructor - * @param {ISignedTransaction=} [properties] Properties to set - */ - function SignedTransaction(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; } - /** - * SignedTransaction signature. - * @member {Uint8Array} signature - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.signature = $util.newBuffer([]); - - /** - * SignedTransaction publicKey. - * @member {google.protobuf.IBytesValue|null|undefined} publicKey - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.publicKey = null; + if (endian !== 'le') return; - /** - * SignedTransaction createAccount. - * @member {ICreateAccountTransaction|null|undefined} createAccount - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.createAccount = null; + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; - /** - * SignedTransaction deployContract. - * @member {IDeployContractTransaction|null|undefined} deployContract - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.deployContract = null; + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } - /** - * SignedTransaction functionCall. - * @member {IFunctionCallTransaction|null|undefined} functionCall - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.functionCall = null; + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } - /** - * SignedTransaction sendMoney. - * @member {ISendMoneyTransaction|null|undefined} sendMoney - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.sendMoney = null; + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; - /** - * SignedTransaction stake. - * @member {IStakeTransaction|null|undefined} stake - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.stake = null; + function parseHex (str, start, end) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; - /** - * SignedTransaction swapKey. - * @member {ISwapKeyTransaction|null|undefined} swapKey - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.swapKey = null; + r <<= 4; - /** - * SignedTransaction addKey. - * @member {IAddKeyTransaction|null|undefined} addKey - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.addKey = null; + // 'a' - 'f' + if (c >= 49 && c <= 54) { + r |= c - 49 + 0xa; - /** - * SignedTransaction deleteKey. - * @member {IDeleteKeyTransaction|null|undefined} deleteKey - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.deleteKey = null; + // 'A' - 'F' + } else if (c >= 17 && c <= 22) { + r |= c - 17 + 0xa; - /** - * SignedTransaction deleteAccount. - * @member {IDeleteAccountTransaction|null|undefined} deleteAccount - * @memberof SignedTransaction - * @instance - */ - SignedTransaction.prototype.deleteAccount = null; + // '0' - '9' + } else { + r |= c & 0xf; + } + } + return r; + } - // OneOf field names bound to virtual getters and setters - var $oneOfFields; + BN.prototype._parseHex = function _parseHex (number, start) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } - /** - * SignedTransaction body. - * @member {"createAccount"|"deployContract"|"functionCall"|"sendMoney"|"stake"|"swapKey"|"addKey"|"deleteKey"|"deleteAccount"|undefined} body - * @memberof SignedTransaction - * @instance - */ - Object.defineProperty(SignedTransaction.prototype, "body", { - get: $util.oneOfGetter($oneOfFields = ["createAccount", "deployContract", "functionCall", "sendMoney", "stake", "swapKey", "addKey", "deleteKey", "deleteAccount"]), - set: $util.oneOfSetter($oneOfFields) - }); + var j, w; + // Scan 24-bit chunks and add them to the number + var off = 0; + for (i = number.length - 6, j = 0; i >= start; i -= 6) { + w = parseHex(number, i, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + if (i + 6 !== start) { + w = parseHex(number, start, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } + this.strip(); + }; - /** - * Creates a new SignedTransaction instance using the specified properties. - * @function create - * @memberof SignedTransaction - * @static - * @param {ISignedTransaction=} [properties] Properties to set - * @returns {SignedTransaction} SignedTransaction instance - */ - SignedTransaction.create = function create(properties) { - return new SignedTransaction(properties); - }; + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; - /** - * Encodes the specified SignedTransaction message. Does not implicitly {@link SignedTransaction.verify|verify} messages. - * @function encode - * @memberof SignedTransaction - * @static - * @param {ISignedTransaction} message SignedTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SignedTransaction.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.signature != null && message.hasOwnProperty("signature")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.signature); - if (message.createAccount != null && message.hasOwnProperty("createAccount")) - $root.CreateAccountTransaction.encode(message.createAccount, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.deployContract != null && message.hasOwnProperty("deployContract")) - $root.DeployContractTransaction.encode(message.deployContract, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.functionCall != null && message.hasOwnProperty("functionCall")) - $root.FunctionCallTransaction.encode(message.functionCall, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - if (message.sendMoney != null && message.hasOwnProperty("sendMoney")) - $root.SendMoneyTransaction.encode(message.sendMoney, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); - if (message.stake != null && message.hasOwnProperty("stake")) - $root.StakeTransaction.encode(message.stake, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); - if (message.swapKey != null && message.hasOwnProperty("swapKey")) - $root.SwapKeyTransaction.encode(message.swapKey, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); - if (message.addKey != null && message.hasOwnProperty("addKey")) - $root.AddKeyTransaction.encode(message.addKey, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); - if (message.deleteKey != null && message.hasOwnProperty("deleteKey")) - $root.DeleteKeyTransaction.encode(message.deleteKey, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - $root.google.protobuf.BytesValue.encode(message.publicKey, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); - if (message.deleteAccount != null && message.hasOwnProperty("deleteAccount")) - $root.DeleteAccountTransaction.encode(message.deleteAccount, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); - return writer; - }; + r *= mul; - /** - * Encodes the specified SignedTransaction message, length delimited. Does not implicitly {@link SignedTransaction.verify|verify} messages. - * @function encodeDelimited - * @memberof SignedTransaction - * @static - * @param {ISignedTransaction} message SignedTransaction message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - SignedTransaction.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; - /** - * Decodes a SignedTransaction message from the specified reader or buffer. - * @function decode - * @memberof SignedTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {SignedTransaction} SignedTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SignedTransaction.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.SignedTransaction(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.signature = reader.bytes(); - break; - case 10: - message.publicKey = $root.google.protobuf.BytesValue.decode(reader, reader.uint32()); - break; - case 2: - message.createAccount = $root.CreateAccountTransaction.decode(reader, reader.uint32()); - break; - case 3: - message.deployContract = $root.DeployContractTransaction.decode(reader, reader.uint32()); - break; - case 4: - message.functionCall = $root.FunctionCallTransaction.decode(reader, reader.uint32()); - break; - case 5: - message.sendMoney = $root.SendMoneyTransaction.decode(reader, reader.uint32()); - break; - case 6: - message.stake = $root.StakeTransaction.decode(reader, reader.uint32()); - break; - case 7: - message.swapKey = $root.SwapKeyTransaction.decode(reader, reader.uint32()); - break; - case 8: - message.addKey = $root.AddKeyTransaction.decode(reader, reader.uint32()); - break; - case 9: - message.deleteKey = $root.DeleteKeyTransaction.decode(reader, reader.uint32()); - break; - case 11: - message.deleteAccount = $root.DeleteAccountTransaction.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; - /** - * Decodes a SignedTransaction message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof SignedTransaction - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {SignedTransaction} SignedTransaction - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - SignedTransaction.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + // '0' - '9' + } else { + r += c; + } + } + return r; + } - /** - * Verifies a SignedTransaction message. - * @function verify - * @memberof SignedTransaction - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - SignedTransaction.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - var properties = {}; - if (message.signature != null && message.hasOwnProperty("signature")) - if (!(message.signature && typeof message.signature.length === "number" || $util.isString(message.signature))) - return "signature: buffer expected"; - if (message.publicKey != null && message.hasOwnProperty("publicKey")) { - var error = $root.google.protobuf.BytesValue.verify(message.publicKey); - if (error) - return "publicKey." + error; - } - if (message.createAccount != null && message.hasOwnProperty("createAccount")) { - properties.body = 1; - { - var error = $root.CreateAccountTransaction.verify(message.createAccount); - if (error) - return "createAccount." + error; - } - } - if (message.deployContract != null && message.hasOwnProperty("deployContract")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.DeployContractTransaction.verify(message.deployContract); - if (error) - return "deployContract." + error; - } - } - if (message.functionCall != null && message.hasOwnProperty("functionCall")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.FunctionCallTransaction.verify(message.functionCall); - if (error) - return "functionCall." + error; - } - } - if (message.sendMoney != null && message.hasOwnProperty("sendMoney")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.SendMoneyTransaction.verify(message.sendMoney); - if (error) - return "sendMoney." + error; - } - } - if (message.stake != null && message.hasOwnProperty("stake")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.StakeTransaction.verify(message.stake); - if (error) - return "stake." + error; - } - } - if (message.swapKey != null && message.hasOwnProperty("swapKey")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.SwapKeyTransaction.verify(message.swapKey); - if (error) - return "swapKey." + error; - } - } - if (message.addKey != null && message.hasOwnProperty("addKey")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.AddKeyTransaction.verify(message.addKey); - if (error) - return "addKey." + error; - } - } - if (message.deleteKey != null && message.hasOwnProperty("deleteKey")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.DeleteKeyTransaction.verify(message.deleteKey); - if (error) - return "deleteKey." + error; - } - } - if (message.deleteAccount != null && message.hasOwnProperty("deleteAccount")) { - if (properties.body === 1) - return "body: multiple values"; - properties.body = 1; - { - var error = $root.DeleteAccountTransaction.verify(message.deleteAccount); - if (error) - return "deleteAccount." + error; - } - } - return null; - }; + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; - /** - * Creates a SignedTransaction message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof SignedTransaction - * @static - * @param {Object.} object Plain object - * @returns {SignedTransaction} SignedTransaction - */ - SignedTransaction.fromObject = function fromObject(object) { - if (object instanceof $root.SignedTransaction) - return object; - var message = new $root.SignedTransaction(); - if (object.signature != null) - if (typeof object.signature === "string") - $util.base64.decode(object.signature, message.signature = $util.newBuffer($util.base64.length(object.signature)), 0); - else if (object.signature.length) - message.signature = object.signature; - if (object.publicKey != null) { - if (typeof object.publicKey !== "object") - throw TypeError(".SignedTransaction.publicKey: object expected"); - message.publicKey = $root.google.protobuf.BytesValue.fromObject(object.publicKey); - } - if (object.createAccount != null) { - if (typeof object.createAccount !== "object") - throw TypeError(".SignedTransaction.createAccount: object expected"); - message.createAccount = $root.CreateAccountTransaction.fromObject(object.createAccount); - } - if (object.deployContract != null) { - if (typeof object.deployContract !== "object") - throw TypeError(".SignedTransaction.deployContract: object expected"); - message.deployContract = $root.DeployContractTransaction.fromObject(object.deployContract); - } - if (object.functionCall != null) { - if (typeof object.functionCall !== "object") - throw TypeError(".SignedTransaction.functionCall: object expected"); - message.functionCall = $root.FunctionCallTransaction.fromObject(object.functionCall); - } - if (object.sendMoney != null) { - if (typeof object.sendMoney !== "object") - throw TypeError(".SignedTransaction.sendMoney: object expected"); - message.sendMoney = $root.SendMoneyTransaction.fromObject(object.sendMoney); - } - if (object.stake != null) { - if (typeof object.stake !== "object") - throw TypeError(".SignedTransaction.stake: object expected"); - message.stake = $root.StakeTransaction.fromObject(object.stake); - } - if (object.swapKey != null) { - if (typeof object.swapKey !== "object") - throw TypeError(".SignedTransaction.swapKey: object expected"); - message.swapKey = $root.SwapKeyTransaction.fromObject(object.swapKey); - } - if (object.addKey != null) { - if (typeof object.addKey !== "object") - throw TypeError(".SignedTransaction.addKey: object expected"); - message.addKey = $root.AddKeyTransaction.fromObject(object.addKey); - } - if (object.deleteKey != null) { - if (typeof object.deleteKey !== "object") - throw TypeError(".SignedTransaction.deleteKey: object expected"); - message.deleteKey = $root.DeleteKeyTransaction.fromObject(object.deleteKey); - } - if (object.deleteAccount != null) { - if (typeof object.deleteAccount !== "object") - throw TypeError(".SignedTransaction.deleteAccount: object expected"); - message.deleteAccount = $root.DeleteAccountTransaction.fromObject(object.deleteAccount); - } - return message; - }; + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; - /** - * Creates a plain object from a SignedTransaction message. Also converts values to other types if specified. - * @function toObject - * @memberof SignedTransaction - * @static - * @param {SignedTransaction} message SignedTransaction - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - SignedTransaction.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - if (options.bytes === String) - object.signature = ""; - else { - object.signature = []; - if (options.bytes !== Array) - object.signature = $util.newBuffer(object.signature); - } - object.publicKey = null; - } - if (message.signature != null && message.hasOwnProperty("signature")) - object.signature = options.bytes === String ? $util.base64.encode(message.signature, 0, message.signature.length) : options.bytes === Array ? Array.prototype.slice.call(message.signature) : message.signature; - if (message.createAccount != null && message.hasOwnProperty("createAccount")) { - object.createAccount = $root.CreateAccountTransaction.toObject(message.createAccount, options); - if (options.oneofs) - object.body = "createAccount"; - } - if (message.deployContract != null && message.hasOwnProperty("deployContract")) { - object.deployContract = $root.DeployContractTransaction.toObject(message.deployContract, options); - if (options.oneofs) - object.body = "deployContract"; - } - if (message.functionCall != null && message.hasOwnProperty("functionCall")) { - object.functionCall = $root.FunctionCallTransaction.toObject(message.functionCall, options); - if (options.oneofs) - object.body = "functionCall"; - } - if (message.sendMoney != null && message.hasOwnProperty("sendMoney")) { - object.sendMoney = $root.SendMoneyTransaction.toObject(message.sendMoney, options); - if (options.oneofs) - object.body = "sendMoney"; - } - if (message.stake != null && message.hasOwnProperty("stake")) { - object.stake = $root.StakeTransaction.toObject(message.stake, options); - if (options.oneofs) - object.body = "stake"; - } - if (message.swapKey != null && message.hasOwnProperty("swapKey")) { - object.swapKey = $root.SwapKeyTransaction.toObject(message.swapKey, options); - if (options.oneofs) - object.body = "swapKey"; - } - if (message.addKey != null && message.hasOwnProperty("addKey")) { - object.addKey = $root.AddKeyTransaction.toObject(message.addKey, options); - if (options.oneofs) - object.body = "addKey"; - } - if (message.deleteKey != null && message.hasOwnProperty("deleteKey")) { - object.deleteKey = $root.DeleteKeyTransaction.toObject(message.deleteKey, options); - if (options.oneofs) - object.body = "deleteKey"; - } - if (message.publicKey != null && message.hasOwnProperty("publicKey")) - object.publicKey = $root.google.protobuf.BytesValue.toObject(message.publicKey, options); - if (message.deleteAccount != null && message.hasOwnProperty("deleteAccount")) { - object.deleteAccount = $root.DeleteAccountTransaction.toObject(message.deleteAccount, options); - if (options.oneofs) - object.body = "deleteAccount"; - } - return object; - }; + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; - /** - * Converts this SignedTransaction to JSON. - * @function toJSON - * @memberof SignedTransaction - * @instance - * @returns {Object.} JSON object - */ - SignedTransaction.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); - return SignedTransaction; -})(); + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } -$root.google = (function() { + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); - /** - * Namespace google. - * @exports google - * @namespace - */ - var google = {}; - - google.protobuf = (function() { - - /** - * Namespace protobuf. - * @memberof google - * @namespace - */ - var protobuf = {}; - - protobuf.DoubleValue = (function() { - - /** - * Properties of a DoubleValue. - * @memberof google.protobuf - * @interface IDoubleValue - * @property {number|null} [value] DoubleValue value - */ - - /** - * Constructs a new DoubleValue. - * @memberof google.protobuf - * @classdesc Represents a DoubleValue. - * @implements IDoubleValue - * @constructor - * @param {google.protobuf.IDoubleValue=} [properties] Properties to set - */ - function DoubleValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + for (i = 0; i < mod; i++) { + pow *= base; + } - /** - * DoubleValue value. - * @member {number} value - * @memberof google.protobuf.DoubleValue - * @instance - */ - DoubleValue.prototype.value = 0; - - /** - * Creates a new DoubleValue instance using the specified properties. - * @function create - * @memberof google.protobuf.DoubleValue - * @static - * @param {google.protobuf.IDoubleValue=} [properties] Properties to set - * @returns {google.protobuf.DoubleValue} DoubleValue instance - */ - DoubleValue.create = function create(properties) { - return new DoubleValue(properties); - }; + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + }; - /** - * Encodes the specified DoubleValue message. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. - * @function encode - * @memberof google.protobuf.DoubleValue - * @static - * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DoubleValue.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 1 =*/9).double(message.value); - return writer; - }; + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; - /** - * Encodes the specified DoubleValue message, length delimited. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.DoubleValue - * @static - * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - DoubleValue.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; - /** - * Decodes a DoubleValue message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.DoubleValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.DoubleValue} DoubleValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DoubleValue.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DoubleValue(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.double(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; - /** - * Decodes a DoubleValue message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.DoubleValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.DoubleValue} DoubleValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - DoubleValue.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; - /** - * Verifies a DoubleValue message. - * @function verify - * @memberof google.protobuf.DoubleValue - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - DoubleValue.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value !== "number") - return "value: number expected"; - return null; - }; + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; - /** - * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.DoubleValue - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.DoubleValue} DoubleValue - */ - DoubleValue.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.DoubleValue) - return object; - var message = new $root.google.protobuf.DoubleValue(); - if (object.value != null) - message.value = Number(object.value); - return message; - }; + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; - /** - * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.DoubleValue - * @static - * @param {google.protobuf.DoubleValue} message DoubleValue - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - DoubleValue.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = 0; - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; - return object; - }; + /* - /** - * Converts this DoubleValue to JSON. - * @function toJSON - * @memberof google.protobuf.DoubleValue - * @instance - * @returns {Object.} JSON object - */ - DoubleValue.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + var zeros = []; + var groupSizes = []; + var groupBases = []; - return DoubleValue; - })(); - - protobuf.FloatValue = (function() { - - /** - * Properties of a FloatValue. - * @memberof google.protobuf - * @interface IFloatValue - * @property {number|null} [value] FloatValue value - */ - - /** - * Constructs a new FloatValue. - * @memberof google.protobuf - * @classdesc Represents a FloatValue. - * @implements IFloatValue - * @constructor - * @param {google.protobuf.IFloatValue=} [properties] Properties to set - */ - function FloatValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } - /** - * FloatValue value. - * @member {number} value - * @memberof google.protobuf.FloatValue - * @instance - */ - FloatValue.prototype.value = 0; - - /** - * Creates a new FloatValue instance using the specified properties. - * @function create - * @memberof google.protobuf.FloatValue - * @static - * @param {google.protobuf.IFloatValue=} [properties] Properties to set - * @returns {google.protobuf.FloatValue} FloatValue instance - */ - FloatValue.create = function create(properties) { - return new FloatValue(properties); - }; + */ - /** - * Encodes the specified FloatValue message. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. - * @function encode - * @memberof google.protobuf.FloatValue - * @static - * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FloatValue.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 5 =*/13).float(message.value); - return writer; - }; + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; - /** - * Encodes the specified FloatValue message, length delimited. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.FloatValue - * @static - * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - FloatValue.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; - /** - * Decodes a FloatValue message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.FloatValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.FloatValue} FloatValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FloatValue.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FloatValue(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.float(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; - /** - * Decodes a FloatValue message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.FloatValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.FloatValue} FloatValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - FloatValue.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; - /** - * Verifies a FloatValue message. - * @function verify - * @memberof google.protobuf.FloatValue - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - FloatValue.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value !== "number") - return "value: number expected"; - return null; - }; + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } - /** - * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.FloatValue - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.FloatValue} FloatValue - */ - FloatValue.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.FloatValue) - return object; - var message = new $root.google.protobuf.FloatValue(); - if (object.value != null) - message.value = Number(object.value); - return message; - }; + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); - /** - * Creates a plain object from a FloatValue message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.FloatValue - * @static - * @param {google.protobuf.FloatValue} message FloatValue - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - FloatValue.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = 0; - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; - return object; - }; + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } - /** - * Converts this FloatValue to JSON. - * @function toJSON - * @memberof google.protobuf.FloatValue - * @instance - * @returns {Object.} JSON object - */ - FloatValue.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + assert(false, 'Base should be between 2 and 36'); + }; - return FloatValue; - })(); - - protobuf.Int64Value = (function() { - - /** - * Properties of an Int64Value. - * @memberof google.protobuf - * @interface IInt64Value - * @property {number|Long|null} [value] Int64Value value - */ - - /** - * Constructs a new Int64Value. - * @memberof google.protobuf - * @classdesc Represents an Int64Value. - * @implements IInt64Value - * @constructor - * @param {google.protobuf.IInt64Value=} [properties] Properties to set - */ - function Int64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Int64Value value. - * @member {number|Long} value - * @memberof google.protobuf.Int64Value - * @instance - */ - Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; - - /** - * Creates a new Int64Value instance using the specified properties. - * @function create - * @memberof google.protobuf.Int64Value - * @static - * @param {google.protobuf.IInt64Value=} [properties] Properties to set - * @returns {google.protobuf.Int64Value} Int64Value instance - */ - Int64Value.create = function create(properties) { - return new Int64Value(properties); - }; + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; - /** - * Encodes the specified Int64Value message. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Int64Value - * @static - * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Int64Value.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 0 =*/8).int64(message.value); - return writer; - }; + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; - /** - * Encodes the specified Int64Value message, length delimited. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Int64Value - * @static - * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Int64Value.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; - /** - * Decodes an Int64Value message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Int64Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Int64Value} Int64Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Int64Value.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int64Value(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.int64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; - /** - * Decodes an Int64Value message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Int64Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Int64Value} Int64Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Int64Value.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); - /** - * Verifies an Int64Value message. - * @function verify - * @memberof google.protobuf.Int64Value - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Int64Value.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) - return "value: integer|Long expected"; - return null; - }; + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); - /** - * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Int64Value - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Int64Value} Int64Value - */ - Int64Value.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Int64Value) - return object; - var message = new $root.google.protobuf.Int64Value(); - if (object.value != null) - if ($util.Long) - (message.value = $util.Long.fromValue(object.value)).unsigned = false; - else if (typeof object.value === "string") - message.value = parseInt(object.value, 10); - else if (typeof object.value === "number") - message.value = object.value; - else if (typeof object.value === "object") - message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); - return message; - }; + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } - /** - * Creates a plain object from an Int64Value message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Int64Value - * @static - * @param {google.protobuf.Int64Value} message Int64Value - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Int64Value.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if ($util.Long) { - var long = new $util.Long(0, 0, false); - object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.value = options.longs === String ? "0" : 0; - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value === "number") - object.value = options.longs === String ? String(message.value) : message.value; - else - object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; - return object; - }; + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - /** - * Converts this Int64Value to JSON. - * @function toJSON - * @memberof google.protobuf.Int64Value - * @instance - * @returns {Object.} JSON object - */ - Int64Value.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); - return Int64Value; - })(); - - protobuf.UInt64Value = (function() { - - /** - * Properties of a UInt64Value. - * @memberof google.protobuf - * @interface IUInt64Value - * @property {number|Long|null} [value] UInt64Value value - */ - - /** - * Constructs a new UInt64Value. - * @memberof google.protobuf - * @classdesc Represents a UInt64Value. - * @implements IUInt64Value - * @constructor - * @param {google.protobuf.IUInt64Value=} [properties] Properties to set - */ - function UInt64Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + res[i] = b; + } - /** - * UInt64Value value. - * @member {number|Long} value - * @memberof google.protobuf.UInt64Value - * @instance - */ - UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; - - /** - * Creates a new UInt64Value instance using the specified properties. - * @function create - * @memberof google.protobuf.UInt64Value - * @static - * @param {google.protobuf.IUInt64Value=} [properties] Properties to set - * @returns {google.protobuf.UInt64Value} UInt64Value instance - */ - UInt64Value.create = function create(properties) { - return new UInt64Value(properties); - }; + for (; i < reqLength; i++) { + res[i] = 0; + } + } - /** - * Encodes the specified UInt64Value message. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. - * @function encode - * @memberof google.protobuf.UInt64Value - * @static - * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UInt64Value.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.value); - return writer; - }; + return res; + }; - /** - * Encodes the specified UInt64Value message, length delimited. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.UInt64Value - * @static - * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UInt64Value.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } - /** - * Decodes a UInt64Value message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.UInt64Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.UInt64Value} UInt64Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UInt64Value.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt64Value(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.uint64(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; - /** - * Decodes a UInt64Value message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.UInt64Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.UInt64Value} UInt64Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UInt64Value.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; - /** - * Verifies a UInt64Value message. - * @function verify - * @memberof google.protobuf.UInt64Value - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - UInt64Value.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) - return "value: integer|Long expected"; - return null; - }; + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; - /** - * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.UInt64Value - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.UInt64Value} UInt64Value - */ - UInt64Value.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.UInt64Value) - return object; - var message = new $root.google.protobuf.UInt64Value(); - if (object.value != null) - if ($util.Long) - (message.value = $util.Long.fromValue(object.value)).unsigned = true; - else if (typeof object.value === "string") - message.value = parseInt(object.value, 10); - else if (typeof object.value === "number") - message.value = object.value; - else if (typeof object.value === "object") - message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(true); - return message; - }; + function toBitArray (num) { + var w = new Array(num.bitLength()); - /** - * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.UInt64Value - * @static - * @param {google.protobuf.UInt64Value} message UInt64Value - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - UInt64Value.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if ($util.Long) { - var long = new $util.Long(0, 0, true); - object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; - } else - object.value = options.longs === String ? "0" : 0; - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value === "number") - object.value = options.longs === String ? String(message.value) : message.value; - else - object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber(true) : message.value; - return object; - }; + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; - /** - * Converts this UInt64Value to JSON. - * @function toJSON - * @memberof google.protobuf.UInt64Value - * @instance - * @returns {Object.} JSON object - */ - UInt64Value.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } - return UInt64Value; - })(); - - protobuf.Int32Value = (function() { - - /** - * Properties of an Int32Value. - * @memberof google.protobuf - * @interface IInt32Value - * @property {number|null} [value] Int32Value value - */ - - /** - * Constructs a new Int32Value. - * @memberof google.protobuf - * @classdesc Represents an Int32Value. - * @implements IInt32Value - * @constructor - * @param {google.protobuf.IInt32Value=} [properties] Properties to set - */ - function Int32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + return w; + } - /** - * Int32Value value. - * @member {number} value - * @memberof google.protobuf.Int32Value - * @instance - */ - Int32Value.prototype.value = 0; - - /** - * Creates a new Int32Value instance using the specified properties. - * @function create - * @memberof google.protobuf.Int32Value - * @static - * @param {google.protobuf.IInt32Value=} [properties] Properties to set - * @returns {google.protobuf.Int32Value} Int32Value instance - */ - Int32Value.create = function create(properties) { - return new Int32Value(properties); - }; + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; - /** - * Encodes the specified Int32Value message. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. - * @function encode - * @memberof google.protobuf.Int32Value - * @static - * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Int32Value.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 0 =*/8).int32(message.value); - return writer; - }; + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; - /** - * Encodes the specified Int32Value message, length delimited. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.Int32Value - * @static - * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Int32Value.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; - /** - * Decodes an Int32Value message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.Int32Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.Int32Value} Int32Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Int32Value.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int32Value(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.int32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; - /** - * Decodes an Int32Value message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.Int32Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.Int32Value} Int32Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Int32Value.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; - /** - * Verifies an Int32Value message. - * @function verify - * @memberof google.protobuf.Int32Value - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Int32Value.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isInteger(message.value)) - return "value: integer expected"; - return null; - }; + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; - /** - * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.Int32Value - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.Int32Value} Int32Value - */ - Int32Value.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.Int32Value) - return object; - var message = new $root.google.protobuf.Int32Value(); - if (object.value != null) - message.value = object.value | 0; - return message; - }; + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; - /** - * Creates a plain object from an Int32Value message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.Int32Value - * @static - * @param {google.protobuf.Int32Value} message Int32Value - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Int32Value.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = 0; - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - return object; - }; + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } - /** - * Converts this Int32Value to JSON. - * @function toJSON - * @memberof google.protobuf.Int32Value - * @instance - * @returns {Object.} JSON object - */ - Int32Value.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + return this; + }; - return Int32Value; - })(); - - protobuf.UInt32Value = (function() { - - /** - * Properties of a UInt32Value. - * @memberof google.protobuf - * @interface IUInt32Value - * @property {number|null} [value] UInt32Value value - */ - - /** - * Constructs a new UInt32Value. - * @memberof google.protobuf - * @classdesc Represents a UInt32Value. - * @implements IUInt32Value - * @constructor - * @param {google.protobuf.IUInt32Value=} [properties] Properties to set - */ - function UInt32Value(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } - /** - * UInt32Value value. - * @member {number} value - * @memberof google.protobuf.UInt32Value - * @instance - */ - UInt32Value.prototype.value = 0; - - /** - * Creates a new UInt32Value instance using the specified properties. - * @function create - * @memberof google.protobuf.UInt32Value - * @static - * @param {google.protobuf.IUInt32Value=} [properties] Properties to set - * @returns {google.protobuf.UInt32Value} UInt32Value instance - */ - UInt32Value.create = function create(properties) { - return new UInt32Value(properties); - }; + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } - /** - * Encodes the specified UInt32Value message. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. - * @function encode - * @memberof google.protobuf.UInt32Value - * @static - * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UInt32Value.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.value); - return writer; - }; + return this.strip(); + }; - /** - * Encodes the specified UInt32Value message, length delimited. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.UInt32Value - * @static - * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - UInt32Value.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; - /** - * Decodes a UInt32Value message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.UInt32Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.UInt32Value} UInt32Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UInt32Value.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt32Value(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.uint32(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; - /** - * Decodes a UInt32Value message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.UInt32Value - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.UInt32Value} UInt32Value - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - UInt32Value.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; - /** - * Verifies a UInt32Value message. - * @function verify - * @memberof google.protobuf.UInt32Value - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - UInt32Value.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isInteger(message.value)) - return "value: integer expected"; - return null; - }; + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } - /** - * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.UInt32Value - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.UInt32Value} UInt32Value - */ - UInt32Value.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.UInt32Value) - return object; - var message = new $root.google.protobuf.UInt32Value(); - if (object.value != null) - message.value = object.value >>> 0; - return message; - }; + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } - /** - * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.UInt32Value - * @static - * @param {google.protobuf.UInt32Value} message UInt32Value - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - UInt32Value.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = 0; - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - return object; - }; + this.length = b.length; - /** - * Converts this UInt32Value to JSON. - * @function toJSON - * @memberof google.protobuf.UInt32Value - * @instance - * @returns {Object.} JSON object - */ - UInt32Value.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + return this.strip(); + }; - return UInt32Value; - })(); - - protobuf.BoolValue = (function() { - - /** - * Properties of a BoolValue. - * @memberof google.protobuf - * @interface IBoolValue - * @property {boolean|null} [value] BoolValue value - */ - - /** - * Constructs a new BoolValue. - * @memberof google.protobuf - * @classdesc Represents a BoolValue. - * @implements IBoolValue - * @constructor - * @param {google.protobuf.IBoolValue=} [properties] Properties to set - */ - function BoolValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; - /** - * BoolValue value. - * @member {boolean} value - * @memberof google.protobuf.BoolValue - * @instance - */ - BoolValue.prototype.value = false; - - /** - * Creates a new BoolValue instance using the specified properties. - * @function create - * @memberof google.protobuf.BoolValue - * @static - * @param {google.protobuf.IBoolValue=} [properties] Properties to set - * @returns {google.protobuf.BoolValue} BoolValue instance - */ - BoolValue.create = function create(properties) { - return new BoolValue(properties); - }; + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; - /** - * Encodes the specified BoolValue message. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. - * @function encode - * @memberof google.protobuf.BoolValue - * @static - * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BoolValue.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 0 =*/8).bool(message.value); - return writer; - }; + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; - /** - * Encodes the specified BoolValue message, length delimited. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.BoolValue - * @static - * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BoolValue.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * Decodes a BoolValue message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.BoolValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.BoolValue} BoolValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BoolValue.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BoolValue(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.bool(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } - /** - * Decodes a BoolValue message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.BoolValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.BoolValue} BoolValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BoolValue.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * Verifies a BoolValue message. - * @function verify - * @memberof google.protobuf.BoolValue - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BoolValue.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (typeof message.value !== "boolean") - return "value: boolean expected"; - return null; - }; + this.length = a.length; - /** - * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.BoolValue - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.BoolValue} BoolValue - */ - BoolValue.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.BoolValue) - return object; - var message = new $root.google.protobuf.BoolValue(); - if (object.value != null) - message.value = Boolean(object.value); - return message; - }; + return this.strip(); + }; - /** - * Creates a plain object from a BoolValue message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.BoolValue - * @static - * @param {google.protobuf.BoolValue} message BoolValue - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BoolValue.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = false; - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - return object; - }; + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; - /** - * Converts this BoolValue to JSON. - * @function toJSON - * @memberof google.protobuf.BoolValue - * @instance - * @returns {Object.} JSON object - */ - BoolValue.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; - return BoolValue; - })(); - - protobuf.StringValue = (function() { - - /** - * Properties of a StringValue. - * @memberof google.protobuf - * @interface IStringValue - * @property {string|null} [value] StringValue value - */ - - /** - * Constructs a new StringValue. - * @memberof google.protobuf - * @classdesc Represents a StringValue. - * @implements IStringValue - * @constructor - * @param {google.protobuf.IStringValue=} [properties] Properties to set - */ - function StringValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; - /** - * StringValue value. - * @member {string} value - * @memberof google.protobuf.StringValue - * @instance - */ - StringValue.prototype.value = ""; - - /** - * Creates a new StringValue instance using the specified properties. - * @function create - * @memberof google.protobuf.StringValue - * @static - * @param {google.protobuf.IStringValue=} [properties] Properties to set - * @returns {google.protobuf.StringValue} StringValue instance - */ - StringValue.create = function create(properties) { - return new StringValue(properties); - }; + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); - /** - * Encodes the specified StringValue message. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. - * @function encode - * @memberof google.protobuf.StringValue - * @static - * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - StringValue.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 2 =*/10).string(message.value); - return writer; - }; + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; - /** - * Encodes the specified StringValue message, length delimited. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.StringValue - * @static - * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - StringValue.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); - /** - * Decodes a StringValue message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.StringValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.StringValue} StringValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - StringValue.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.StringValue(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.string(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + if (bitsLeft > 0) { + bytesNeeded--; + } - /** - * Decodes a StringValue message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.StringValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.StringValue} StringValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - StringValue.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } - /** - * Verifies a StringValue message. - * @function verify - * @memberof google.protobuf.StringValue - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - StringValue.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!$util.isString(message.value)) - return "value: string expected"; - return null; - }; + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } - /** - * Creates a StringValue message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.StringValue - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.StringValue} StringValue - */ - StringValue.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.StringValue) - return object; - var message = new $root.google.protobuf.StringValue(); - if (object.value != null) - message.value = String(object.value); - return message; - }; + // And remove leading zeroes + return this.strip(); + }; - /** - * Creates a plain object from a StringValue message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.StringValue - * @static - * @param {google.protobuf.StringValue} message StringValue - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - StringValue.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - object.value = ""; - if (message.value != null && message.hasOwnProperty("value")) - object.value = message.value; - return object; - }; + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; - /** - * Converts this StringValue to JSON. - * @function toJSON - * @memberof google.protobuf.StringValue - * @instance - * @returns {Object.} JSON object - */ - StringValue.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); - return StringValue; - })(); - - protobuf.BytesValue = (function() { - - /** - * Properties of a BytesValue. - * @memberof google.protobuf - * @interface IBytesValue - * @property {Uint8Array|null} [value] BytesValue value - */ - - /** - * Constructs a new BytesValue. - * @memberof google.protobuf - * @classdesc Represents a BytesValue. - * @implements IBytesValue - * @constructor - * @param {google.protobuf.IBytesValue=} [properties] Properties to set - */ - function BytesValue(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } + var off = (bit / 26) | 0; + var wbit = bit % 26; - /** - * BytesValue value. - * @member {Uint8Array} value - * @memberof google.protobuf.BytesValue - * @instance - */ - BytesValue.prototype.value = $util.newBuffer([]); - - /** - * Creates a new BytesValue instance using the specified properties. - * @function create - * @memberof google.protobuf.BytesValue - * @static - * @param {google.protobuf.IBytesValue=} [properties] Properties to set - * @returns {google.protobuf.BytesValue} BytesValue instance - */ - BytesValue.create = function create(properties) { - return new BytesValue(properties); - }; + this._expand(off + 1); - /** - * Encodes the specified BytesValue message. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. - * @function encode - * @memberof google.protobuf.BytesValue - * @static - * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BytesValue.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.value != null && message.hasOwnProperty("value")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.value); - return writer; - }; + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } - /** - * Encodes the specified BytesValue message, length delimited. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. - * @function encodeDelimited - * @memberof google.protobuf.BytesValue - * @static - * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - BytesValue.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; + return this.strip(); + }; - /** - * Decodes a BytesValue message from the specified reader or buffer. - * @function decode - * @memberof google.protobuf.BytesValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {google.protobuf.BytesValue} BytesValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BytesValue.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BytesValue(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.value = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; - /** - * Decodes a BytesValue message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof google.protobuf.BytesValue - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {google.protobuf.BytesValue} BytesValue - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - BytesValue.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); - /** - * Verifies a BytesValue message. - * @function verify - * @memberof google.protobuf.BytesValue - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - BytesValue.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.value != null && message.hasOwnProperty("value")) - if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) - return "value: buffer expected"; - return null; - }; + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } - /** - * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof google.protobuf.BytesValue - * @static - * @param {Object.} object Plain object - * @returns {google.protobuf.BytesValue} BytesValue - */ - BytesValue.fromObject = function fromObject(object) { - if (object instanceof $root.google.protobuf.BytesValue) - return object; - var message = new $root.google.protobuf.BytesValue(); - if (object.value != null) - if (typeof object.value === "string") - $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); - else if (object.value.length) - message.value = object.value; - return message; - }; + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * Creates a plain object from a BytesValue message. Also converts values to other types if specified. - * @function toObject - * @memberof google.protobuf.BytesValue - * @static - * @param {google.protobuf.BytesValue} message BytesValue - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - BytesValue.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if (options.bytes === String) - object.value = ""; - else { - object.value = []; - if (options.bytes !== Array) - object.value = $util.newBuffer(object.value); - } - if (message.value != null && message.hasOwnProperty("value")) - object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; - return object; - }; + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } - /** - * Converts this BytesValue to JSON. - * @function toJSON - * @memberof google.protobuf.BytesValue - * @instance - * @returns {Object.} JSON object - */ - BytesValue.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - return BytesValue; - })(); + return this; + }; - return protobuf; - })(); + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } - return google; -})(); + if (this.length > num.length) return this.clone().iadd(num); -$root.AccessKey = (function() { + return num.clone().iadd(this); + }; - /** - * Properties of an AccessKey. - * @exports IAccessKey - * @interface IAccessKey - * @property {IUint128|null} [amount] AccessKey amount - * @property {google.protobuf.IStringValue|null} [balanceOwner] AccessKey balanceOwner - * @property {google.protobuf.IStringValue|null} [contractId] AccessKey contractId - * @property {google.protobuf.IBytesValue|null} [methodName] AccessKey methodName - */ + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); - /** - * Constructs a new AccessKey. - * @exports AccessKey - * @classdesc Represents an AccessKey. - * @implements IAccessKey - * @constructor - * @param {IAccessKey=} [properties] Properties to set - */ - function AccessKey(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); } - /** - * AccessKey amount. - * @member {IUint128|null|undefined} amount - * @memberof AccessKey - * @instance - */ - AccessKey.prototype.amount = null; + // At this point both numbers are positive + var cmp = this.cmp(num); - /** - * AccessKey balanceOwner. - * @member {google.protobuf.IStringValue|null|undefined} balanceOwner - * @memberof AccessKey - * @instance - */ - AccessKey.prototype.balanceOwner = null; + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } - /** - * AccessKey contractId. - * @member {google.protobuf.IStringValue|null|undefined} contractId - * @memberof AccessKey - * @instance - */ - AccessKey.prototype.contractId = null; + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } - /** - * AccessKey methodName. - * @member {google.protobuf.IBytesValue|null|undefined} methodName - * @memberof AccessKey - * @instance - */ - AccessKey.prototype.methodName = null; + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } - /** - * Creates a new AccessKey instance using the specified properties. - * @function create - * @memberof AccessKey - * @static - * @param {IAccessKey=} [properties] Properties to set - * @returns {AccessKey} AccessKey instance - */ - AccessKey.create = function create(properties) { - return new AccessKey(properties); - }; + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } - /** - * Encodes the specified AccessKey message. Does not implicitly {@link AccessKey.verify|verify} messages. - * @function encode - * @memberof AccessKey - * @static - * @param {IAccessKey} message AccessKey message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AccessKey.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.amount != null && message.hasOwnProperty("amount")) - $root.Uint128.encode(message.amount, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); - if (message.balanceOwner != null && message.hasOwnProperty("balanceOwner")) - $root.google.protobuf.StringValue.encode(message.balanceOwner, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); - if (message.contractId != null && message.hasOwnProperty("contractId")) - $root.google.protobuf.StringValue.encode(message.contractId, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); - if (message.methodName != null && message.hasOwnProperty("methodName")) - $root.google.protobuf.BytesValue.encode(message.methodName, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); - return writer; - }; + this.length = Math.max(this.length, i); - /** - * Encodes the specified AccessKey message, length delimited. Does not implicitly {@link AccessKey.verify|verify} messages. - * @function encodeDelimited - * @memberof AccessKey - * @static - * @param {IAccessKey} message AccessKey message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - AccessKey.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an AccessKey message from the specified reader or buffer. - * @function decode - * @memberof AccessKey - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {AccessKey} AccessKey - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AccessKey.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.AccessKey(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.amount = $root.Uint128.decode(reader, reader.uint32()); - break; - case 2: - message.balanceOwner = $root.google.protobuf.StringValue.decode(reader, reader.uint32()); - break; - case 3: - message.contractId = $root.google.protobuf.StringValue.decode(reader, reader.uint32()); - break; - case 4: - message.methodName = $root.google.protobuf.BytesValue.decode(reader, reader.uint32()); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an AccessKey message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof AccessKey - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {AccessKey} AccessKey - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - AccessKey.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an AccessKey message. - * @function verify - * @memberof AccessKey - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - AccessKey.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.amount != null && message.hasOwnProperty("amount")) { - var error = $root.Uint128.verify(message.amount); - if (error) - return "amount." + error; - } - if (message.balanceOwner != null && message.hasOwnProperty("balanceOwner")) { - var error = $root.google.protobuf.StringValue.verify(message.balanceOwner); - if (error) - return "balanceOwner." + error; - } - if (message.contractId != null && message.hasOwnProperty("contractId")) { - var error = $root.google.protobuf.StringValue.verify(message.contractId); - if (error) - return "contractId." + error; - } - if (message.methodName != null && message.hasOwnProperty("methodName")) { - var error = $root.google.protobuf.BytesValue.verify(message.methodName); - if (error) - return "methodName." + error; - } - return null; - }; - - /** - * Creates an AccessKey message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof AccessKey - * @static - * @param {Object.} object Plain object - * @returns {AccessKey} AccessKey - */ - AccessKey.fromObject = function fromObject(object) { - if (object instanceof $root.AccessKey) - return object; - var message = new $root.AccessKey(); - if (object.amount != null) { - if (typeof object.amount !== "object") - throw TypeError(".AccessKey.amount: object expected"); - message.amount = $root.Uint128.fromObject(object.amount); - } - if (object.balanceOwner != null) { - if (typeof object.balanceOwner !== "object") - throw TypeError(".AccessKey.balanceOwner: object expected"); - message.balanceOwner = $root.google.protobuf.StringValue.fromObject(object.balanceOwner); - } - if (object.contractId != null) { - if (typeof object.contractId !== "object") - throw TypeError(".AccessKey.contractId: object expected"); - message.contractId = $root.google.protobuf.StringValue.fromObject(object.contractId); - } - if (object.methodName != null) { - if (typeof object.methodName !== "object") - throw TypeError(".AccessKey.methodName: object expected"); - message.methodName = $root.google.protobuf.BytesValue.fromObject(object.methodName); - } - return message; - }; - - /** - * Creates a plain object from an AccessKey message. Also converts values to other types if specified. - * @function toObject - * @memberof AccessKey - * @static - * @param {AccessKey} message AccessKey - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - AccessKey.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) { - object.amount = null; - object.balanceOwner = null; - object.contractId = null; - object.methodName = null; - } - if (message.amount != null && message.hasOwnProperty("amount")) - object.amount = $root.Uint128.toObject(message.amount, options); - if (message.balanceOwner != null && message.hasOwnProperty("balanceOwner")) - object.balanceOwner = $root.google.protobuf.StringValue.toObject(message.balanceOwner, options); - if (message.contractId != null && message.hasOwnProperty("contractId")) - object.contractId = $root.google.protobuf.StringValue.toObject(message.contractId, options); - if (message.methodName != null && message.hasOwnProperty("methodName")) - object.methodName = $root.google.protobuf.BytesValue.toObject(message.methodName, options); - return object; - }; - - /** - * Converts this AccessKey to JSON. - * @function toJSON - * @memberof AccessKey - * @instance - * @returns {Object.} JSON object - */ - AccessKey.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return AccessKey; -})(); - -$root.Uint128 = (function() { - - /** - * Properties of an Uint128. - * @exports IUint128 - * @interface IUint128 - * @property {Uint8Array|null} [number] Uint128 number - */ - - /** - * Constructs a new Uint128. - * @exports Uint128 - * @classdesc Provides container for unsigned 128 bit integers. - * @implements IUint128 - * @constructor - * @param {IUint128=} [properties] Properties to set - */ - function Uint128(properties) { - if (properties) - for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) - if (properties[keys[i]] != null) - this[keys[i]] = properties[keys[i]]; - } - - /** - * Uint128 number. - * @member {Uint8Array} number - * @memberof Uint128 - * @instance - */ - Uint128.prototype.number = $util.newBuffer([]); - - /** - * Creates a new Uint128 instance using the specified properties. - * @function create - * @memberof Uint128 - * @static - * @param {IUint128=} [properties] Properties to set - * @returns {Uint128} Uint128 instance - */ - Uint128.create = function create(properties) { - return new Uint128(properties); - }; - - /** - * Encodes the specified Uint128 message. Does not implicitly {@link Uint128.verify|verify} messages. - * @function encode - * @memberof Uint128 - * @static - * @param {IUint128} message Uint128 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Uint128.encode = function encode(message, writer) { - if (!writer) - writer = $Writer.create(); - if (message.number != null && message.hasOwnProperty("number")) - writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.number); - return writer; - }; - - /** - * Encodes the specified Uint128 message, length delimited. Does not implicitly {@link Uint128.verify|verify} messages. - * @function encodeDelimited - * @memberof Uint128 - * @static - * @param {IUint128} message Uint128 message or plain object to encode - * @param {$protobuf.Writer} [writer] Writer to encode to - * @returns {$protobuf.Writer} Writer - */ - Uint128.encodeDelimited = function encodeDelimited(message, writer) { - return this.encode(message, writer).ldelim(); - }; - - /** - * Decodes an Uint128 message from the specified reader or buffer. - * @function decode - * @memberof Uint128 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @param {number} [length] Message length if known beforehand - * @returns {Uint128} Uint128 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Uint128.decode = function decode(reader, length) { - if (!(reader instanceof $Reader)) - reader = $Reader.create(reader); - var end = length === undefined ? reader.len : reader.pos + length, message = new $root.Uint128(); - while (reader.pos < end) { - var tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - message.number = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return message; - }; - - /** - * Decodes an Uint128 message from the specified reader or buffer, length delimited. - * @function decodeDelimited - * @memberof Uint128 - * @static - * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from - * @returns {Uint128} Uint128 - * @throws {Error} If the payload is not a reader or valid buffer - * @throws {$protobuf.util.ProtocolError} If required fields are missing - */ - Uint128.decodeDelimited = function decodeDelimited(reader) { - if (!(reader instanceof $Reader)) - reader = new $Reader(reader); - return this.decode(reader, reader.uint32()); - }; - - /** - * Verifies an Uint128 message. - * @function verify - * @memberof Uint128 - * @static - * @param {Object.} message Plain object to verify - * @returns {string|null} `null` if valid, otherwise the reason why it is not - */ - Uint128.verify = function verify(message) { - if (typeof message !== "object" || message === null) - return "object expected"; - if (message.number != null && message.hasOwnProperty("number")) - if (!(message.number && typeof message.number.length === "number" || $util.isString(message.number))) - return "number: buffer expected"; - return null; - }; - - /** - * Creates an Uint128 message from a plain object. Also converts values to their respective internal types. - * @function fromObject - * @memberof Uint128 - * @static - * @param {Object.} object Plain object - * @returns {Uint128} Uint128 - */ - Uint128.fromObject = function fromObject(object) { - if (object instanceof $root.Uint128) - return object; - var message = new $root.Uint128(); - if (object.number != null) - if (typeof object.number === "string") - $util.base64.decode(object.number, message.number = $util.newBuffer($util.base64.length(object.number)), 0); - else if (object.number.length) - message.number = object.number; - return message; - }; - - /** - * Creates a plain object from an Uint128 message. Also converts values to other types if specified. - * @function toObject - * @memberof Uint128 - * @static - * @param {Uint128} message Uint128 - * @param {$protobuf.IConversionOptions} [options] Conversion options - * @returns {Object.} Plain object - */ - Uint128.toObject = function toObject(message, options) { - if (!options) - options = {}; - var object = {}; - if (options.defaults) - if (options.bytes === String) - object.number = ""; - else { - object.number = []; - if (options.bytes !== Array) - object.number = $util.newBuffer(object.number); - } - if (message.number != null && message.hasOwnProperty("number")) - object.number = options.bytes === String ? $util.base64.encode(message.number, 0, message.number.length) : options.bytes === Array ? Array.prototype.slice.call(message.number) : message.number; - return object; - }; - - /** - * Converts this Uint128 to JSON. - * @function toJSON - * @memberof Uint128 - * @instance - * @returns {Object.} JSON object - */ - Uint128.prototype.toJSON = function toJSON() { - return this.constructor.toObject(this, $protobuf.util.toJSONOptions); - }; - - return Uint128; -})(); - -module.exports = $root; - -},{"protobufjs/minimal":64}],15:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const provider_1 = require("./provider"); -exports.Provider = provider_1.Provider; -exports.getTransactionLastResult = provider_1.getTransactionLastResult; -const json_rpc_provider_1 = require("./json-rpc-provider"); -exports.JsonRpcProvider = json_rpc_provider_1.JsonRpcProvider; - -},{"./json-rpc-provider":16,"./provider":17}],16:[function(require,module,exports){ -(function (Buffer){ -'use strict'; -Object.defineProperty(exports, "__esModule", { value: true }); -const provider_1 = require("./provider"); -const web_1 = require("../utils/web"); -const serialize_1 = require("../utils/serialize"); -const protos_1 = require("../protos"); -/// Keep ids unique across all connections. -let _nextId = 123; -class JsonRpcProvider extends provider_1.Provider { - constructor(url, network) { - super(); - // TODO: resolve network to url... - this.connection = { url }; - } - async getNetwork() { - return { - name: 'test', - chainId: 'test' - }; - } - async status() { - return this.sendJsonRpc('status', []); - } - async sendTransaction(signedTransaction) { - const bytes = protos_1.SignedTransaction.encode(signedTransaction).finish(); - return this.sendJsonRpc('broadcast_tx_commit', [Buffer.from(bytes).toString('base64')]); - } - async txStatus(txHash) { - return this.sendJsonRpc('tx', [serialize_1.base_encode(txHash)]); - } - async query(path, data) { - const result = await this.sendJsonRpc('query', [path, data]); - if (result.error) { - throw new Error(`Quering ${path} failed: ${result.error}.\n${JSON.stringify(result, null, 2)}`); - } - return result; - } - async block(height) { - return this.sendJsonRpc('block', [height]); - } - async sendJsonRpc(method, params) { - const request = { - method, - params, - id: (_nextId++), - jsonrpc: '2.0' - }; - const result = await web_1.fetchJson(this.connection, JSON.stringify(request)); - if (result.error) { - throw new Error(`[${result.error.code}] ${result.error.message}: ${result.error.data}`); - } - return result.result; - } -} -exports.JsonRpcProvider = JsonRpcProvider; - -}).call(this,require("buffer").Buffer) -},{"../protos":14,"../utils/serialize":23,"../utils/web":24,"./provider":17,"buffer":39}],17:[function(require,module,exports){ -(function (Buffer){ -'use strict'; -Object.defineProperty(exports, "__esModule", { value: true }); -var FinalTransactionStatus; -(function (FinalTransactionStatus) { - FinalTransactionStatus["Unknown"] = "Unknown"; - FinalTransactionStatus["Started"] = "Started"; - FinalTransactionStatus["Failed"] = "Failed"; - FinalTransactionStatus["Completed"] = "Completed"; -})(FinalTransactionStatus = exports.FinalTransactionStatus || (exports.FinalTransactionStatus = {})); -class Provider { -} -exports.Provider = Provider; -function getTransactionLastResult(txResult) { - for (let i = txResult.logs.length - 1; i >= 0; --i) { - const r = txResult.logs[i]; - if (r.result && r.result.length > 0) { - return JSON.parse(Buffer.from(r.result).toString()); - } - } - return null; -} -exports.getTransactionLastResult = getTransactionLastResult; - -}).call(this,require("buffer").Buffer) -},{"buffer":39}],18:[function(require,module,exports){ -'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const js_sha256_1 = __importDefault(require("js-sha256")); -const key_pair_1 = require("./utils/key_pair"); -/** - * General signing interface, can be used for in memory signing, RPC singing, external wallet, HSM, etc. - */ -class Signer { - /** - * Signs given message, by first hashing with sha256. - * @param message message to sign. - * @param accountId accountId to use for signing. - * @param networkId network for this accontId. - */ - async signMessage(message, accountId, networkId) { - return this.signHash(new Uint8Array(js_sha256_1.default.sha256.array(message)), accountId, networkId); - } -} -exports.Signer = Signer; -/** - * Signs using in memory key store. - */ -class InMemorySigner extends Signer { - constructor(keyStore) { - super(); - this.keyStore = keyStore; - } - async createKey(accountId, networkId) { - const keyPair = key_pair_1.KeyPair.fromRandom('ed25519'); - await this.keyStore.setKey(networkId, accountId, keyPair); - return keyPair.getPublicKey(); - } - async getPublicKey(accountId, networkId) { - const keyPair = await this.keyStore.getKey(networkId, accountId); - return keyPair.getPublicKey(); - } - async signHash(hash, accountId, networkId) { - if (!accountId) { - throw new Error('InMemorySigner requires provided account id'); - } - const keyPair = await this.keyStore.getKey(networkId, accountId); - if (keyPair === null) { - throw new Error(`Key for ${accountId} not found in ${networkId}`); - } - return keyPair.sign(hash); - } -} -exports.InMemorySigner = InMemorySigner; - -},{"./utils/key_pair":21,"js-sha256":58}],19:[function(require,module,exports){ -(function (Buffer){ -'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const js_sha256_1 = __importDefault(require("js-sha256")); -const bn_js_1 = __importDefault(require("bn.js")); -const protos_1 = require("./protos"); -const serialize_1 = require("./utils/serialize"); -const TRANSACTION_FIELD_MAP = new Map([ - [protos_1.CreateAccountTransaction, 'createAccount'], - [protos_1.DeployContractTransaction, 'deployContract'], - [protos_1.FunctionCallTransaction, 'functionCall'], - [protos_1.SendMoneyTransaction, 'sendMoney'], - [protos_1.StakeTransaction, 'stake'], - [protos_1.SwapKeyTransaction, 'swapKey'], - [protos_1.AddKeyTransaction, 'addKey'], - [protos_1.DeleteKeyTransaction, 'deleteKey'], -]); -function bigInt(num) { - const number = new Uint8Array(new bn_js_1.default(num).toArray('le', 16)); - return new protos_1.Uint128({ number }); -} -function bignumHex2Dec(num) { - return new bn_js_1.default(num, 16).toString(10); -} -exports.bignumHex2Dec = bignumHex2Dec; -function createAccount(nonce, originator, newAccountId, publicKey, amount) { - return new protos_1.CreateAccountTransaction({ nonce, originator, newAccountId, publicKey: serialize_1.base_decode(publicKey), amount: bigInt(amount) }); -} -exports.createAccount = createAccount; -function deployContract(nonce, contractId, wasmByteArray) { - return new protos_1.DeployContractTransaction({ nonce, contractId, wasmByteArray }); -} -exports.deployContract = deployContract; -function functionCall(nonce, originator, contractId, methodName, args, amount) { - return new protos_1.FunctionCallTransaction({ nonce, originator, contractId, methodName: Buffer.from(methodName), args, amount: bigInt(amount) }); -} -exports.functionCall = functionCall; -function sendMoney(nonce, originator, receiver, amount) { - return new protos_1.SendMoneyTransaction({ nonce, originator, receiver, amount: bigInt(amount) }); -} -exports.sendMoney = sendMoney; -function stake(nonce, originator, amount, publicKey) { - return new protos_1.StakeTransaction({ nonce, originator, amount: bigInt(amount), publicKey, blsPublicKey: null }); -} -exports.stake = stake; -function swapKey(nonce, originator, curKey, newKey) { - return new protos_1.SwapKeyTransaction({ nonce, originator, curKey: serialize_1.base_decode(curKey), newKey: serialize_1.base_decode(newKey) }); -} -exports.swapKey = swapKey; -function createAccessKey(contractId, methodName, balanceOwner, amount) { - return new protos_1.AccessKey({ - contractId: contractId ? new protos_1.google.protobuf.StringValue({ value: contractId }) : null, - methodName: methodName ? new protos_1.google.protobuf.BytesValue({ value: Buffer.from(methodName) }) : null, - balanceOwner: balanceOwner ? new protos_1.google.protobuf.StringValue({ value: balanceOwner }) : null, - amount: bigInt(amount || new bn_js_1.default(0)), - }); -} -exports.createAccessKey = createAccessKey; -function addKey(nonce, originator, newKey, accessKey) { - return new protos_1.AddKeyTransaction({ nonce, originator, newKey: serialize_1.base_decode(newKey), accessKey }); -} -exports.addKey = addKey; -function deleteKey(nonce, originator, curKey) { - return new protos_1.DeleteKeyTransaction({ nonce, originator, curKey: serialize_1.base_decode(curKey) }); -} -exports.deleteKey = deleteKey; -function signedTransaction(transaction, signature) { - const fieldName = TRANSACTION_FIELD_MAP.get(transaction.constructor); - return new protos_1.SignedTransaction({ - signature: signature.signature, - publicKey: protos_1.google.protobuf.BytesValue.create({ value: serialize_1.base_decode(signature.publicKey) }), - [fieldName]: transaction, - }); -} -exports.signedTransaction = signedTransaction; -async function signTransaction(signer, transaction, accountId, networkId) { - const protoClass = transaction.constructor; - const message = protoClass.encode(transaction).finish(); - const hash = new Uint8Array(js_sha256_1.default.sha256.array(message)); - const signature = await signer.signHash(hash, accountId, networkId); - return [hash, signedTransaction(transaction, signature)]; -} -exports.signTransaction = signTransaction; - -}).call(this,require("buffer").Buffer) -},{"./protos":14,"./utils/serialize":23,"bn.js":35,"buffer":39,"js-sha256":58}],20:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const key_pair = __importStar(require("./key_pair")); -exports.key_pair = key_pair; -const network = __importStar(require("./network")); -exports.network = network; -const serialize = __importStar(require("./serialize")); -exports.serialize = serialize; -const web = __importStar(require("./web")); -exports.web = web; -const key_pair_1 = require("./key_pair"); -exports.KeyPair = key_pair_1.KeyPair; -exports.KeyPairEd25519 = key_pair_1.KeyPairEd25519; - -},{"./key_pair":21,"./network":22,"./serialize":23,"./web":24}],21:[function(require,module,exports){ -'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const tweetnacl_1 = __importDefault(require("tweetnacl")); -const serialize_1 = require("./serialize"); -class KeyPair { - static fromRandom(curve) { - switch (curve) { - case 'ed25519': return KeyPairEd25519.fromRandom(); - default: throw new Error(`Unknown curve ${curve}`); - } - } - static fromString(encodedKey) { - const parts = encodedKey.split(':'); - if (parts.length !== 2) { - throw new Error('Invalid encoded key format, must be :'); - } - switch (parts[0]) { - case 'ed25519': return new KeyPairEd25519(parts[1]); - default: throw new Error(`Unknown curve: ${parts[0]}`); - } - } -} -exports.KeyPair = KeyPair; -/** - * This class provides key pair functionality for Ed25519 curve: - * generating key pairs, encoding key pairs, signing and verifying. - */ -class KeyPairEd25519 extends KeyPair { - /** - * Construct an instance of key pair given a secret key. - * It's generally assumed that these are encoded in base58. - * @param {string} secretKey - */ - constructor(secretKey) { - super(); - const keyPair = tweetnacl_1.default.sign.keyPair.fromSecretKey(serialize_1.base_decode(secretKey)); - this.publicKey = serialize_1.base_encode(keyPair.publicKey); - this.secretKey = secretKey; - } - /** - * Generate a new random keypair. - * @example - * const keyRandom = KeyPair.fromRandom(); - * keyRandom.publicKey - * // returns [PUBLIC_KEY] - * - * keyRandom.secretKey - * // returns [SECRET_KEY] - */ - static fromRandom() { - const newKeyPair = tweetnacl_1.default.sign.keyPair(); - return new KeyPairEd25519(serialize_1.base_encode(newKeyPair.secretKey)); - } - sign(message) { - const signature = tweetnacl_1.default.sign.detached(message, serialize_1.base_decode(this.secretKey)); - return { signature, publicKey: this.publicKey }; - } - verify(message, signature) { - return tweetnacl_1.default.sign.detached.verify(message, signature, serialize_1.base_decode(this.publicKey)); - } - toString() { - return `ed25519:${this.secretKey}`; - } - getPublicKey() { - return this.publicKey; - } -} -exports.KeyPairEd25519 = KeyPairEd25519; - -},{"./serialize":23,"tweetnacl":80}],22:[function(require,module,exports){ -'use strict'; -Object.defineProperty(exports, "__esModule", { value: true }); - -},{}],23:[function(require,module,exports){ -(function (Buffer){ -'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const bs58_1 = __importDefault(require("bs58")); -function base_encode(value) { - if (typeof (value) === 'string') { - value = Buffer.from(value, 'utf8'); - } - return bs58_1.default.encode(Buffer.from(value)); -} -exports.base_encode = base_encode; -function base_decode(value) { - return bs58_1.default.decode(value); -} -exports.base_decode = base_decode; - -}).call(this,require("buffer").Buffer) -},{"bs58":38,"buffer":39}],24:[function(require,module,exports){ -'use strict'; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const http_errors_1 = __importDefault(require("http-errors")); -const fetch = (typeof window === 'undefined' || window.name === 'nodejs') ? require('node-fetch') : window.fetch; -async function fetchJson(connection, json) { - let url = null; - if (typeof (connection) === 'string') { - url = connection; - } - else { - url = connection.url; - } - const response = await fetch(url, { - method: json ? 'POST' : 'GET', - body: json ? json : undefined, - headers: { 'Content-type': 'application/json; charset=utf-8' } - }); - if (!response.ok) { - throw http_errors_1.default(response.status, await response.text()); - } - return await response.json(); -} -exports.fetchJson = fetchJson; - -},{"http-errors":55,"node-fetch":37}],25:[function(require,module,exports){ -'use strict'; -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("./utils"); -const LOGIN_WALLET_URL_SUFFIX = '/login/'; -const LOCAL_STORAGE_KEY_SUFFIX = '_wallet_auth_key'; -const PENDING_ACCESS_KEY_PREFIX = 'pending_key'; // browser storage key for a pending access key (i.e. key has been generated but we are not sure it was added yet) -class WalletAccount { - constructor(near, appKeyPrefix) { - this._networkId = near.config.networkId; - this._walletBaseUrl = near.config.walletUrl; - appKeyPrefix = appKeyPrefix || near.config.contractName || 'default'; - this._authDataKey = appKeyPrefix + LOCAL_STORAGE_KEY_SUFFIX; - this._keyStore = near.connection.signer.keyStore; - this._authData = JSON.parse(window.localStorage.getItem(this._authDataKey) || '{}'); - if (!this.isSignedIn()) { - this._completeSignInWithAccessKey(); - } - } - /** - * Returns true, if this WalletAccount is authorized with the wallet. - * @example - * walletAccount.isSignedIn(); - */ - isSignedIn() { - return !!this._authData.accountId; - } - /** - * Returns authorized Account ID. - * @example - * walletAccount.getAccountId(); - */ - getAccountId() { - return this._authData.accountId || ''; - } - /** - * Redirects current page to the wallet authentication page. - * @param {string} contractId contract ID of the application - * @param {string} title name of the application - * @param {string} successUrl url to redirect on success - * @param {string} failureUrl url to redirect on failure - * @example - * walletAccount.requestSignIn( - * myContractId, - * title, - * onSuccessHref, - * onFailureHref); - */ - async requestSignIn(contractId, title, successUrl, failureUrl) { - if (this.getAccountId() || await this._keyStore.getKey(this._networkId, this.getAccountId())) { - return Promise.resolve(); - } - const currentUrl = new URL(window.location.href); - const newUrl = new URL(this._walletBaseUrl + LOGIN_WALLET_URL_SUFFIX); - newUrl.searchParams.set('title', title); - newUrl.searchParams.set('contract_id', contractId); - newUrl.searchParams.set('success_url', successUrl || currentUrl.href); - newUrl.searchParams.set('failure_url', failureUrl || currentUrl.href); - newUrl.searchParams.set('app_url', currentUrl.origin); - const accessKey = utils_1.KeyPair.fromRandom('ed25519'); - newUrl.searchParams.set('public_key', accessKey.getPublicKey()); - await this._keyStore.setKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + accessKey.getPublicKey(), accessKey); - window.location.assign(newUrl.toString()); - } - /** - * Complete sign in for a given account id and public key. To be invoked by the app when getting a callback from the wallet. - */ - async _completeSignInWithAccessKey() { - const currentUrl = new URL(window.location.href); - const publicKey = currentUrl.searchParams.get('public_key') || ''; - const accountId = currentUrl.searchParams.get('account_id') || ''; - if (accountId && publicKey) { - this._authData = { - accountId - }; - window.localStorage.setItem(this._authDataKey, JSON.stringify(this._authData)); - await this._moveKeyFromTempToPermanent(accountId, publicKey); - } - } - async _moveKeyFromTempToPermanent(accountId, publicKey) { - const keyPair = await this._keyStore.getKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + publicKey); - await this._keyStore.setKey(this._networkId, accountId, keyPair); - await this._keyStore.removeKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + publicKey); - } - /** - * Sign out from the current account - * @example - * walletAccount.signOut(); - */ - signOut() { - this._authData = {}; - window.localStorage.removeItem(this._authDataKey); - } -} -exports.WalletAccount = WalletAccount; - -},{"./utils":20}],26:[function(require,module,exports){ -"use strict"; -module.exports = asPromise; - -/** - * Callback as used by {@link util.asPromise}. - * @typedef asPromiseCallback - * @type {function} - * @param {Error|null} error Error, if any - * @param {...*} params Additional arguments - * @returns {undefined} - */ - -/** - * Returns a promise from a node-style callback function. - * @memberof util - * @param {asPromiseCallback} fn Function to call - * @param {*} ctx Function context - * @param {...*} params Function arguments - * @returns {Promise<*>} Promisified function - */ -function asPromise(fn, ctx/*, varargs */) { - var params = new Array(arguments.length - 1), - offset = 0, - index = 2, - pending = true; - while (index < arguments.length) - params[offset++] = arguments[index++]; - return new Promise(function executor(resolve, reject) { - params[offset] = function callback(err/*, varargs */) { - if (pending) { - pending = false; - if (err) - reject(err); - else { - var params = new Array(arguments.length - 1), - offset = 0; - while (offset < params.length) - params[offset++] = arguments[offset]; - resolve.apply(null, params); - } - } - }; - try { - fn.apply(ctx || null, params); - } catch (err) { - if (pending) { - pending = false; - reject(err); - } - } - }); -} - -},{}],27:[function(require,module,exports){ -"use strict"; - -/** - * A minimal base64 implementation for number arrays. - * @memberof util - * @namespace - */ -var base64 = exports; - -/** - * Calculates the byte length of a base64 encoded string. - * @param {string} string Base64 encoded string - * @returns {number} Byte length - */ -base64.length = function length(string) { - var p = string.length; - if (!p) - return 0; - var n = 0; - while (--p % 4 > 1 && string.charAt(p) === "=") - ++n; - return Math.ceil(string.length * 3) / 4 - n; -}; - -// Base64 encoding table -var b64 = new Array(64); - -// Base64 decoding table -var s64 = new Array(123); - -// 65..90, 97..122, 48..57, 43, 47 -for (var i = 0; i < 64;) - s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; - -/** - * Encodes a buffer to a base64 encoded string. - * @param {Uint8Array} buffer Source buffer - * @param {number} start Source start - * @param {number} end Source end - * @returns {string} Base64 encoded string - */ -base64.encode = function encode(buffer, start, end) { - var parts = null, - chunk = []; - var i = 0, // output index - j = 0, // goto index - t; // temporary - while (start < end) { - var b = buffer[start++]; - switch (j) { - case 0: - chunk[i++] = b64[b >> 2]; - t = (b & 3) << 4; - j = 1; - break; - case 1: - chunk[i++] = b64[t | b >> 4]; - t = (b & 15) << 2; - j = 2; - break; - case 2: - chunk[i++] = b64[t | b >> 6]; - chunk[i++] = b64[b & 63]; - j = 0; - break; - } - if (i > 8191) { - (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); - i = 0; - } - } - if (j) { - chunk[i++] = b64[t]; - chunk[i++] = 61; - if (j === 1) - chunk[i++] = 61; - } - if (parts) { - if (i) - parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); - return parts.join(""); - } - return String.fromCharCode.apply(String, chunk.slice(0, i)); -}; - -var invalidEncoding = "invalid encoding"; - -/** - * Decodes a base64 encoded string to a buffer. - * @param {string} string Source string - * @param {Uint8Array} buffer Destination buffer - * @param {number} offset Destination offset - * @returns {number} Number of bytes written - * @throws {Error} If encoding is invalid - */ -base64.decode = function decode(string, buffer, offset) { - var start = offset; - var j = 0, // goto index - t; // temporary - for (var i = 0; i < string.length;) { - var c = string.charCodeAt(i++); - if (c === 61 && j > 1) - break; - if ((c = s64[c]) === undefined) - throw Error(invalidEncoding); - switch (j) { - case 0: - t = c; - j = 1; - break; - case 1: - buffer[offset++] = t << 2 | (c & 48) >> 4; - t = c; - j = 2; - break; - case 2: - buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2; - t = c; - j = 3; - break; - case 3: - buffer[offset++] = (t & 3) << 6 | c; - j = 0; - break; - } - } - if (j === 1) - throw Error(invalidEncoding); - return offset - start; -}; - -/** - * Tests if the specified string appears to be base64 encoded. - * @param {string} string String to test - * @returns {boolean} `true` if probably base64 encoded, otherwise false - */ -base64.test = function test(string) { - return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string); -}; - -},{}],28:[function(require,module,exports){ -"use strict"; -module.exports = EventEmitter; - -/** - * Constructs a new event emitter instance. - * @classdesc A minimal event emitter. - * @memberof util - * @constructor - */ -function EventEmitter() { - - /** - * Registered listeners. - * @type {Object.} - * @private - */ - this._listeners = {}; -} - -/** - * Registers an event listener. - * @param {string} evt Event name - * @param {function} fn Listener - * @param {*} [ctx] Listener context - * @returns {util.EventEmitter} `this` - */ -EventEmitter.prototype.on = function on(evt, fn, ctx) { - (this._listeners[evt] || (this._listeners[evt] = [])).push({ - fn : fn, - ctx : ctx || this - }); - return this; -}; - -/** - * Removes an event listener or any matching listeners if arguments are omitted. - * @param {string} [evt] Event name. Removes all listeners if omitted. - * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted. - * @returns {util.EventEmitter} `this` - */ -EventEmitter.prototype.off = function off(evt, fn) { - if (evt === undefined) - this._listeners = {}; - else { - if (fn === undefined) - this._listeners[evt] = []; - else { - var listeners = this._listeners[evt]; - for (var i = 0; i < listeners.length;) - if (listeners[i].fn === fn) - listeners.splice(i, 1); - else - ++i; - } - } - return this; -}; - -/** - * Emits an event by calling its listeners with the specified arguments. - * @param {string} evt Event name - * @param {...*} args Arguments - * @returns {util.EventEmitter} `this` - */ -EventEmitter.prototype.emit = function emit(evt) { - var listeners = this._listeners[evt]; - if (listeners) { - var args = [], - i = 1; - for (; i < arguments.length;) - args.push(arguments[i++]); - for (i = 0; i < listeners.length;) - listeners[i].fn.apply(listeners[i++].ctx, args); - } - return this; -}; - -},{}],29:[function(require,module,exports){ -"use strict"; - -module.exports = factory(factory); - -/** - * Reads / writes floats / doubles from / to buffers. - * @name util.float - * @namespace - */ - -/** - * Writes a 32 bit float to a buffer using little endian byte order. - * @name util.float.writeFloatLE - * @function - * @param {number} val Value to write - * @param {Uint8Array} buf Target buffer - * @param {number} pos Target buffer offset - * @returns {undefined} - */ - -/** - * Writes a 32 bit float to a buffer using big endian byte order. - * @name util.float.writeFloatBE - * @function - * @param {number} val Value to write - * @param {Uint8Array} buf Target buffer - * @param {number} pos Target buffer offset - * @returns {undefined} - */ - -/** - * Reads a 32 bit float from a buffer using little endian byte order. - * @name util.float.readFloatLE - * @function - * @param {Uint8Array} buf Source buffer - * @param {number} pos Source buffer offset - * @returns {number} Value read - */ - -/** - * Reads a 32 bit float from a buffer using big endian byte order. - * @name util.float.readFloatBE - * @function - * @param {Uint8Array} buf Source buffer - * @param {number} pos Source buffer offset - * @returns {number} Value read - */ - -/** - * Writes a 64 bit double to a buffer using little endian byte order. - * @name util.float.writeDoubleLE - * @function - * @param {number} val Value to write - * @param {Uint8Array} buf Target buffer - * @param {number} pos Target buffer offset - * @returns {undefined} - */ - -/** - * Writes a 64 bit double to a buffer using big endian byte order. - * @name util.float.writeDoubleBE - * @function - * @param {number} val Value to write - * @param {Uint8Array} buf Target buffer - * @param {number} pos Target buffer offset - * @returns {undefined} - */ - -/** - * Reads a 64 bit double from a buffer using little endian byte order. - * @name util.float.readDoubleLE - * @function - * @param {Uint8Array} buf Source buffer - * @param {number} pos Source buffer offset - * @returns {number} Value read - */ - -/** - * Reads a 64 bit double from a buffer using big endian byte order. - * @name util.float.readDoubleBE - * @function - * @param {Uint8Array} buf Source buffer - * @param {number} pos Source buffer offset - * @returns {number} Value read - */ - -// Factory function for the purpose of node-based testing in modified global environments -function factory(exports) { - - // float: typed array - if (typeof Float32Array !== "undefined") (function() { - - var f32 = new Float32Array([ -0 ]), - f8b = new Uint8Array(f32.buffer), - le = f8b[3] === 128; - - function writeFloat_f32_cpy(val, buf, pos) { - f32[0] = val; - buf[pos ] = f8b[0]; - buf[pos + 1] = f8b[1]; - buf[pos + 2] = f8b[2]; - buf[pos + 3] = f8b[3]; - } - - function writeFloat_f32_rev(val, buf, pos) { - f32[0] = val; - buf[pos ] = f8b[3]; - buf[pos + 1] = f8b[2]; - buf[pos + 2] = f8b[1]; - buf[pos + 3] = f8b[0]; - } - - /* istanbul ignore next */ - exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev; - /* istanbul ignore next */ - exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy; - - function readFloat_f32_cpy(buf, pos) { - f8b[0] = buf[pos ]; - f8b[1] = buf[pos + 1]; - f8b[2] = buf[pos + 2]; - f8b[3] = buf[pos + 3]; - return f32[0]; - } - - function readFloat_f32_rev(buf, pos) { - f8b[3] = buf[pos ]; - f8b[2] = buf[pos + 1]; - f8b[1] = buf[pos + 2]; - f8b[0] = buf[pos + 3]; - return f32[0]; - } - - /* istanbul ignore next */ - exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev; - /* istanbul ignore next */ - exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy; - - // float: ieee754 - })(); else (function() { - - function writeFloat_ieee754(writeUint, val, buf, pos) { - var sign = val < 0 ? 1 : 0; - if (sign) - val = -val; - if (val === 0) - writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos); - else if (isNaN(val)) - writeUint(2143289344, buf, pos); - else if (val > 3.4028234663852886e+38) // +-Infinity - writeUint((sign << 31 | 2139095040) >>> 0, buf, pos); - else if (val < 1.1754943508222875e-38) // denormal - writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos); - else { - var exponent = Math.floor(Math.log(val) / Math.LN2), - mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607; - writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos); - } - } - - exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE); - exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE); - - function readFloat_ieee754(readUint, buf, pos) { - var uint = readUint(buf, pos), - sign = (uint >> 31) * 2 + 1, - exponent = uint >>> 23 & 255, - mantissa = uint & 8388607; - return exponent === 255 - ? mantissa - ? NaN - : sign * Infinity - : exponent === 0 // denormal - ? sign * 1.401298464324817e-45 * mantissa - : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608); - } - - exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE); - exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE); - - })(); - - // double: typed array - if (typeof Float64Array !== "undefined") (function() { - - var f64 = new Float64Array([-0]), - f8b = new Uint8Array(f64.buffer), - le = f8b[7] === 128; - - function writeDouble_f64_cpy(val, buf, pos) { - f64[0] = val; - buf[pos ] = f8b[0]; - buf[pos + 1] = f8b[1]; - buf[pos + 2] = f8b[2]; - buf[pos + 3] = f8b[3]; - buf[pos + 4] = f8b[4]; - buf[pos + 5] = f8b[5]; - buf[pos + 6] = f8b[6]; - buf[pos + 7] = f8b[7]; - } - - function writeDouble_f64_rev(val, buf, pos) { - f64[0] = val; - buf[pos ] = f8b[7]; - buf[pos + 1] = f8b[6]; - buf[pos + 2] = f8b[5]; - buf[pos + 3] = f8b[4]; - buf[pos + 4] = f8b[3]; - buf[pos + 5] = f8b[2]; - buf[pos + 6] = f8b[1]; - buf[pos + 7] = f8b[0]; - } - - /* istanbul ignore next */ - exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev; - /* istanbul ignore next */ - exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy; - - function readDouble_f64_cpy(buf, pos) { - f8b[0] = buf[pos ]; - f8b[1] = buf[pos + 1]; - f8b[2] = buf[pos + 2]; - f8b[3] = buf[pos + 3]; - f8b[4] = buf[pos + 4]; - f8b[5] = buf[pos + 5]; - f8b[6] = buf[pos + 6]; - f8b[7] = buf[pos + 7]; - return f64[0]; - } - - function readDouble_f64_rev(buf, pos) { - f8b[7] = buf[pos ]; - f8b[6] = buf[pos + 1]; - f8b[5] = buf[pos + 2]; - f8b[4] = buf[pos + 3]; - f8b[3] = buf[pos + 4]; - f8b[2] = buf[pos + 5]; - f8b[1] = buf[pos + 6]; - f8b[0] = buf[pos + 7]; - return f64[0]; - } - - /* istanbul ignore next */ - exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev; - /* istanbul ignore next */ - exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy; - - // double: ieee754 - })(); else (function() { - - function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) { - var sign = val < 0 ? 1 : 0; - if (sign) - val = -val; - if (val === 0) { - writeUint(0, buf, pos + off0); - writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1); - } else if (isNaN(val)) { - writeUint(0, buf, pos + off0); - writeUint(2146959360, buf, pos + off1); - } else if (val > 1.7976931348623157e+308) { // +-Infinity - writeUint(0, buf, pos + off0); - writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1); - } else { - var mantissa; - if (val < 2.2250738585072014e-308) { // denormal - mantissa = val / 5e-324; - writeUint(mantissa >>> 0, buf, pos + off0); - writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1); - } else { - var exponent = Math.floor(Math.log(val) / Math.LN2); - if (exponent === 1024) - exponent = 1023; - mantissa = val * Math.pow(2, -exponent); - writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0); - writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1); - } - } - } - - exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4); - exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0); - - function readDouble_ieee754(readUint, off0, off1, buf, pos) { - var lo = readUint(buf, pos + off0), - hi = readUint(buf, pos + off1); - var sign = (hi >> 31) * 2 + 1, - exponent = hi >>> 20 & 2047, - mantissa = 4294967296 * (hi & 1048575) + lo; - return exponent === 2047 - ? mantissa - ? NaN - : sign * Infinity - : exponent === 0 // denormal - ? sign * 5e-324 * mantissa - : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496); - } - - exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4); - exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0); - - })(); - - return exports; -} - -// uint helpers - -function writeUintLE(val, buf, pos) { - buf[pos ] = val & 255; - buf[pos + 1] = val >>> 8 & 255; - buf[pos + 2] = val >>> 16 & 255; - buf[pos + 3] = val >>> 24; -} - -function writeUintBE(val, buf, pos) { - buf[pos ] = val >>> 24; - buf[pos + 1] = val >>> 16 & 255; - buf[pos + 2] = val >>> 8 & 255; - buf[pos + 3] = val & 255; -} - -function readUintLE(buf, pos) { - return (buf[pos ] - | buf[pos + 1] << 8 - | buf[pos + 2] << 16 - | buf[pos + 3] << 24) >>> 0; -} - -function readUintBE(buf, pos) { - return (buf[pos ] << 24 - | buf[pos + 1] << 16 - | buf[pos + 2] << 8 - | buf[pos + 3]) >>> 0; -} - -},{}],30:[function(require,module,exports){ -"use strict"; -module.exports = inquire; - -/** - * Requires a module only if available. - * @memberof util - * @param {string} moduleName Module to require - * @returns {?Object} Required module if available and not empty, otherwise `null` - */ -function inquire(moduleName) { - try { - var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval - if (mod && (mod.length || Object.keys(mod).length)) - return mod; - } catch (e) {} // eslint-disable-line no-empty - return null; -} - -},{}],31:[function(require,module,exports){ -"use strict"; -module.exports = pool; - -/** - * An allocator as used by {@link util.pool}. - * @typedef PoolAllocator - * @type {function} - * @param {number} size Buffer size - * @returns {Uint8Array} Buffer - */ - -/** - * A slicer as used by {@link util.pool}. - * @typedef PoolSlicer - * @type {function} - * @param {number} start Start offset - * @param {number} end End offset - * @returns {Uint8Array} Buffer slice - * @this {Uint8Array} - */ - -/** - * A general purpose buffer pool. - * @memberof util - * @function - * @param {PoolAllocator} alloc Allocator - * @param {PoolSlicer} slice Slicer - * @param {number} [size=8192] Slab size - * @returns {PoolAllocator} Pooled allocator - */ -function pool(alloc, slice, size) { - var SIZE = size || 8192; - var MAX = SIZE >>> 1; - var slab = null; - var offset = SIZE; - return function pool_alloc(size) { - if (size < 1 || size > MAX) - return alloc(size); - if (offset + size > SIZE) { - slab = alloc(SIZE); - offset = 0; - } - var buf = slice.call(slab, offset, offset += size); - if (offset & 7) // align to 32 bit - offset = (offset | 7) + 1; - return buf; - }; -} - -},{}],32:[function(require,module,exports){ -"use strict"; - -/** - * A minimal UTF8 implementation for number arrays. - * @memberof util - * @namespace - */ -var utf8 = exports; - -/** - * Calculates the UTF8 byte length of a string. - * @param {string} string String - * @returns {number} Byte length - */ -utf8.length = function utf8_length(string) { - var len = 0, - c = 0; - for (var i = 0; i < string.length; ++i) { - c = string.charCodeAt(i); - if (c < 128) - len += 1; - else if (c < 2048) - len += 2; - else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) { - ++i; - len += 4; - } else - len += 3; - } - return len; -}; - -/** - * Reads UTF8 bytes as a string. - * @param {Uint8Array} buffer Source buffer - * @param {number} start Source start - * @param {number} end Source end - * @returns {string} String read - */ -utf8.read = function utf8_read(buffer, start, end) { - var len = end - start; - if (len < 1) - return ""; - var parts = null, - chunk = [], - i = 0, // char offset - t; // temporary - while (start < end) { - t = buffer[start++]; - if (t < 128) - chunk[i++] = t; - else if (t > 191 && t < 224) - chunk[i++] = (t & 31) << 6 | buffer[start++] & 63; - else if (t > 239 && t < 365) { - t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000; - chunk[i++] = 0xD800 + (t >> 10); - chunk[i++] = 0xDC00 + (t & 1023); - } else - chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63; - if (i > 8191) { - (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk)); - i = 0; - } - } - if (parts) { - if (i) - parts.push(String.fromCharCode.apply(String, chunk.slice(0, i))); - return parts.join(""); - } - return String.fromCharCode.apply(String, chunk.slice(0, i)); -}; - -/** - * Writes a string as UTF8 bytes. - * @param {string} string Source string - * @param {Uint8Array} buffer Destination buffer - * @param {number} offset Destination offset - * @returns {number} Bytes written - */ -utf8.write = function utf8_write(string, buffer, offset) { - var start = offset, - c1, // character 1 - c2; // character 2 - for (var i = 0; i < string.length; ++i) { - c1 = string.charCodeAt(i); - if (c1 < 128) { - buffer[offset++] = c1; - } else if (c1 < 2048) { - buffer[offset++] = c1 >> 6 | 192; - buffer[offset++] = c1 & 63 | 128; - } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) { - c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF); - ++i; - buffer[offset++] = c1 >> 18 | 240; - buffer[offset++] = c1 >> 12 & 63 | 128; - buffer[offset++] = c1 >> 6 & 63 | 128; - buffer[offset++] = c1 & 63 | 128; - } else { - buffer[offset++] = c1 >> 12 | 224; - buffer[offset++] = c1 >> 6 & 63 | 128; - buffer[offset++] = c1 & 63 | 128; - } - } - return offset - start; -}; - -},{}],33:[function(require,module,exports){ -// base-x encoding / decoding -// Copyright (c) 2018 base-x contributors -// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp) -// Distributed under the MIT software license, see the accompanying -// file LICENSE or http://www.opensource.org/licenses/mit-license.php. - -const Buffer = require('safe-buffer').Buffer - -module.exports = function base (ALPHABET) { - if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long') - - const BASE_MAP = new Uint8Array(256) - BASE_MAP.fill(255) - - for (let i = 0; i < ALPHABET.length; i++) { - const x = ALPHABET.charAt(i) - const xc = x.charCodeAt(0) - - if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous') - BASE_MAP[xc] = i - } - - const BASE = ALPHABET.length - const LEADER = ALPHABET.charAt(0) - const FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up - const iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up - - function encode (source) { - if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer') - if (source.length === 0) return '' - - // Skip & count leading zeroes. - let zeroes = 0 - let length = 0 - let pbegin = 0 - const pend = source.length - - while (pbegin !== pend && source[pbegin] === 0) { - pbegin++ - zeroes++ - } - - // Allocate enough space in big-endian base58 representation. - const size = ((pend - pbegin) * iFACTOR + 1) >>> 0 - const b58 = new Uint8Array(size) - - // Process the bytes. - while (pbegin !== pend) { - let carry = source[pbegin] - - // Apply "b58 = b58 * 256 + ch". - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (256 * b58[it]) >>> 0 - b58[it] = (carry % BASE) >>> 0 - carry = (carry / BASE) >>> 0 - } - - if (carry !== 0) throw new Error('Non-zero carry') - length = i - pbegin++ - } - - // Skip leading zeroes in base58 result. - let it = size - length - while (it !== size && b58[it] === 0) { - it++ - } - - // Translate the result into a string. - let str = LEADER.repeat(zeroes) - for (; it < size; ++it) str += ALPHABET.charAt(b58[it]) - - return str - } - - function decodeUnsafe (source) { - if (typeof source !== 'string') throw new TypeError('Expected String') - if (source.length === 0) return Buffer.alloc(0) - - let psz = 0 - - // Skip leading spaces. - if (source[psz] === ' ') return - - // Skip and count leading '1's. - let zeroes = 0 - let length = 0 - while (source[psz] === LEADER) { - zeroes++ - psz++ - } - - // Allocate enough space in big-endian base256 representation. - const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. - const b256 = new Uint8Array(size) - - // Process the characters. - while (source[psz]) { - // Decode character - let carry = BASE_MAP[source.charCodeAt(psz)] - - // Invalid character - if (carry === 255) return - - let i = 0 - for (let it = size - 1; (carry !== 0 || i < length) && (it !== -1); it--, i++) { - carry += (BASE * b256[it]) >>> 0 - b256[it] = (carry % 256) >>> 0 - carry = (carry / 256) >>> 0 - } - - if (carry !== 0) throw new Error('Non-zero carry') - length = i - psz++ - } - - // Skip trailing spaces. - if (source[psz] === ' ') return - - // Skip leading zeroes in b256. - let it = size - length - while (it !== size && b256[it] === 0) { - it++ - } - - const vch = Buffer.allocUnsafe(zeroes + (size - it)) - vch.fill(0x00, 0, zeroes) - - let j = zeroes - while (it !== size) { - vch[j++] = b256[it++] - } - - return vch - } - - function decode (string) { - const buffer = decodeUnsafe(string) - if (buffer) return buffer - - throw new Error('Non-base' + BASE + ' character') - } - - return { - encode: encode, - decodeUnsafe: decodeUnsafe, - decode: decode - } -} - -},{"safe-buffer":75}],34:[function(require,module,exports){ -'use strict' - -exports.byteLength = byteLength -exports.toByteArray = toByteArray -exports.fromByteArray = fromByteArray - -var lookup = [] -var revLookup = [] -var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array - -var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -for (var i = 0, len = code.length; i < len; ++i) { - lookup[i] = code[i] - revLookup[code.charCodeAt(i)] = i -} - -// Support decoding URL-safe base64 strings, as Node.js does. -// See: https://en.wikipedia.org/wiki/Base64#URL_applications -revLookup['-'.charCodeAt(0)] = 62 -revLookup['_'.charCodeAt(0)] = 63 - -function getLens (b64) { - var len = b64.length - - if (len % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // Trim off extra bytes after placeholder bytes are found - // See: https://github.com/beatgammit/base64-js/issues/42 - var validLen = b64.indexOf('=') - if (validLen === -1) validLen = len - - var placeHoldersLen = validLen === len - ? 0 - : 4 - (validLen % 4) - - return [validLen, placeHoldersLen] -} - -// base64 is 4/3 + up to two characters of the original data -function byteLength (b64) { - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function _byteLength (b64, validLen, placeHoldersLen) { - return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen -} - -function toByteArray (b64) { - var tmp - var lens = getLens(b64) - var validLen = lens[0] - var placeHoldersLen = lens[1] - - var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen)) - - var curByte = 0 - - // if there are placeholders, only get up to the last complete 4 chars - var len = placeHoldersLen > 0 - ? validLen - 4 - : validLen - - for (var i = 0; i < len; i += 4) { - tmp = - (revLookup[b64.charCodeAt(i)] << 18) | - (revLookup[b64.charCodeAt(i + 1)] << 12) | - (revLookup[b64.charCodeAt(i + 2)] << 6) | - revLookup[b64.charCodeAt(i + 3)] - arr[curByte++] = (tmp >> 16) & 0xFF - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 2) { - tmp = - (revLookup[b64.charCodeAt(i)] << 2) | - (revLookup[b64.charCodeAt(i + 1)] >> 4) - arr[curByte++] = tmp & 0xFF - } - - if (placeHoldersLen === 1) { - tmp = - (revLookup[b64.charCodeAt(i)] << 10) | - (revLookup[b64.charCodeAt(i + 1)] << 4) | - (revLookup[b64.charCodeAt(i + 2)] >> 2) - arr[curByte++] = (tmp >> 8) & 0xFF - arr[curByte++] = tmp & 0xFF - } - - return arr -} - -function tripletToBase64 (num) { - return lookup[num >> 18 & 0x3F] + - lookup[num >> 12 & 0x3F] + - lookup[num >> 6 & 0x3F] + - lookup[num & 0x3F] -} - -function encodeChunk (uint8, start, end) { - var tmp - var output = [] - for (var i = start; i < end; i += 3) { - tmp = - ((uint8[i] << 16) & 0xFF0000) + - ((uint8[i + 1] << 8) & 0xFF00) + - (uint8[i + 2] & 0xFF) - output.push(tripletToBase64(tmp)) - } - return output.join('') -} - -function fromByteArray (uint8) { - var tmp - var len = uint8.length - var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes - var parts = [] - var maxChunkLength = 16383 // must be multiple of 3 - - // go through the array every three bytes, we'll deal with trailing stuff later - for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { - parts.push(encodeChunk( - uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength) - )) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - if (extraBytes === 1) { - tmp = uint8[len - 1] - parts.push( - lookup[tmp >> 2] + - lookup[(tmp << 4) & 0x3F] + - '==' - ) - } else if (extraBytes === 2) { - tmp = (uint8[len - 2] << 8) + uint8[len - 1] - parts.push( - lookup[tmp >> 10] + - lookup[(tmp >> 4) & 0x3F] + - lookup[(tmp << 2) & 0x3F] + - '=' - ) - } - - return parts.join('') -} - -},{}],35:[function(require,module,exports){ -(function (module, exports) { - 'use strict'; - - // Utils - function assert (val, msg) { - if (!val) throw new Error(msg || 'Assertion failed'); - } - - // Could use `inherits` module, but don't want to move from single file - // architecture yet. - function inherits (ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - - // BN - - function BN (number, base, endian) { - if (BN.isBN(number)) { - return number; - } - - this.negative = 0; - this.words = null; - this.length = 0; - - // Reduction context - this.red = null; - - if (number !== null) { - if (base === 'le' || base === 'be') { - endian = base; - base = 10; - } - - this._init(number || 0, base || 10, endian || 'be'); - } - } - if (typeof module === 'object') { - module.exports = BN; - } else { - exports.BN = BN; - } - - BN.BN = BN; - BN.wordSize = 26; - - var Buffer; - try { - Buffer = require('buffer').Buffer; - } catch (e) { - } - - BN.isBN = function isBN (num) { - if (num instanceof BN) { - return true; - } - - return num !== null && typeof num === 'object' && - num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); - }; - - BN.max = function max (left, right) { - if (left.cmp(right) > 0) return left; - return right; - }; - - BN.min = function min (left, right) { - if (left.cmp(right) < 0) return left; - return right; - }; - - BN.prototype._init = function init (number, base, endian) { - if (typeof number === 'number') { - return this._initNumber(number, base, endian); - } - - if (typeof number === 'object') { - return this._initArray(number, base, endian); - } - - if (base === 'hex') { - base = 16; - } - assert(base === (base | 0) && base >= 2 && base <= 36); - - number = number.toString().replace(/\s+/g, ''); - var start = 0; - if (number[0] === '-') { - start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { - this.negative = 1; - } - - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initNumber = function _initNumber (number, base, endian) { - if (number < 0) { - this.negative = 1; - number = -number; - } - if (number < 0x4000000) { - this.words = [ number & 0x3ffffff ]; - this.length = 1; - } else if (number < 0x10000000000000) { - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff - ]; - this.length = 2; - } else { - assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff, - 1 - ]; - this.length = 3; - } - - if (endian !== 'le') return; - - // Reverse the bytes - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initArray = function _initArray (number, base, endian) { - // Perhaps a Uint8Array - assert(typeof number.length === 'number'); - if (number.length <= 0) { - this.words = [ 0 ]; - this.length = 1; - return this; - } - - this.length = Math.ceil(number.length / 3); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - var off = 0; - if (endian === 'be') { - for (i = number.length - 1, j = 0; i >= 0; i -= 3) { - w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } else if (endian === 'le') { - for (i = 0, j = 0; i < number.length; i += 3) { - w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } - return this.strip(); - }; - - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; - - // '0' - '9' - } else { - r |= c & 0xf; - } - } - return r; - } - - BN.prototype._parseHex = function _parseHex (number, start) { - // Create possibly bigger array to ensure that it fits the number - this.length = Math.ceil((number.length - start) / 6); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - // Scan 24-bit chunks and add them to the number - var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - } - this.strip(); - }; - - function parseBase (str, start, end, mul) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r *= mul; - - // 'a' - if (c >= 49) { - r += c - 49 + 0xa; - - // 'A' - } else if (c >= 17) { - r += c - 17 + 0xa; - - // '0' - '9' - } else { - r += c; - } - } - return r; - } - - BN.prototype._parseBase = function _parseBase (number, base, start) { - // Initialize as zero - this.words = [ 0 ]; - this.length = 1; - - // Find length of limb in base - for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { - limbLen++; - } - limbLen--; - limbPow = (limbPow / base) | 0; - - var total = number.length - start; - var mod = total % limbLen; - var end = Math.min(total, total - mod) + start; - - var word = 0; - for (var i = start; i < end; i += limbLen) { - word = parseBase(number, i, i + limbLen, base); - - this.imuln(limbPow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - if (mod !== 0) { - var pow = 1; - word = parseBase(number, i, number.length, base); - - for (i = 0; i < mod; i++) { - pow *= base; - } - - this.imuln(pow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - }; - - BN.prototype.copy = function copy (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - dest.words[i] = this.words[i]; - } - dest.length = this.length; - dest.negative = this.negative; - dest.red = this.red; - }; - - BN.prototype.clone = function clone () { - var r = new BN(null); - this.copy(r); - return r; - }; - - BN.prototype._expand = function _expand (size) { - while (this.length < size) { - this.words[this.length++] = 0; - } - return this; - }; - - // Remove leading `0` from `this` - BN.prototype.strip = function strip () { - while (this.length > 1 && this.words[this.length - 1] === 0) { - this.length--; - } - return this._normSign(); - }; - - BN.prototype._normSign = function _normSign () { - // -0 = 0 - if (this.length === 1 && this.words[0] === 0) { - this.negative = 0; - } - return this; - }; - - BN.prototype.inspect = function inspect () { - return (this.red ? ''; - }; - - /* - - var zeros = []; - var groupSizes = []; - var groupBases = []; - - var s = ''; - var i = -1; - while (++i < BN.wordSize) { - zeros[i] = s; - s += '0'; - } - groupSizes[0] = 0; - groupSizes[1] = 0; - groupBases[0] = 0; - groupBases[1] = 0; - var base = 2 - 1; - while (++base < 36 + 1) { - var groupSize = 0; - var groupBase = 1; - while (groupBase < (1 << BN.wordSize) / base) { - groupBase *= base; - groupSize += 1; - } - groupSizes[base] = groupSize; - groupBases[base] = groupBase; - } - - */ - - var zeros = [ - '', - '0', - '00', - '000', - '0000', - '00000', - '000000', - '0000000', - '00000000', - '000000000', - '0000000000', - '00000000000', - '000000000000', - '0000000000000', - '00000000000000', - '000000000000000', - '0000000000000000', - '00000000000000000', - '000000000000000000', - '0000000000000000000', - '00000000000000000000', - '000000000000000000000', - '0000000000000000000000', - '00000000000000000000000', - '000000000000000000000000', - '0000000000000000000000000' - ]; - - var groupSizes = [ - 0, 0, - 25, 16, 12, 11, 10, 9, 8, - 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5 - ]; - - var groupBases = [ - 0, 0, - 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, - 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, - 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, - 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, - 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 - ]; - - BN.prototype.toString = function toString (base, padding) { - base = base || 10; - padding = padding | 0 || 1; - - var out; - if (base === 16 || base === 'hex') { - out = ''; - var off = 0; - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = this.words[i]; - var word = (((w << off) | carry) & 0xffffff).toString(16); - carry = (w >>> (24 - off)) & 0xffffff; - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - } - if (carry !== 0) { - out = carry.toString(16) + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - if (base === (base | 0) && base >= 2 && base <= 36) { - // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); - var groupSize = groupSizes[base]; - // var groupBase = Math.pow(base, groupSize); - var groupBase = groupBases[base]; - out = ''; - var c = this.clone(); - c.negative = 0; - while (!c.isZero()) { - var r = c.modn(groupBase).toString(base); - c = c.idivn(groupBase); - - if (!c.isZero()) { - out = zeros[groupSize - r.length] + r + out; - } else { - out = r + out; - } - } - if (this.isZero()) { - out = '0' + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - assert(false, 'Base should be between 2 and 36'); - }; - - BN.prototype.toNumber = function toNumber () { - var ret = this.words[0]; - if (this.length === 2) { - ret += this.words[1] * 0x4000000; - } else if (this.length === 3 && this.words[2] === 0x01) { - // NOTE: at this stage it is known that the top bit is set - ret += 0x10000000000000 + (this.words[1] * 0x4000000); - } else if (this.length > 2) { - assert(false, 'Number can only safely store up to 53 bits'); - } - return (this.negative !== 0) ? -ret : ret; - }; - - BN.prototype.toJSON = function toJSON () { - return this.toString(16); - }; - - BN.prototype.toBuffer = function toBuffer (endian, length) { - assert(typeof Buffer !== 'undefined'); - return this.toArrayLike(Buffer, endian, length); - }; - - BN.prototype.toArray = function toArray (endian, length) { - return this.toArrayLike(Array, endian, length); - }; - - BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { - var byteLength = this.byteLength(); - var reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, 'byte array longer than desired length'); - assert(reqLength > 0, 'Requested array length <= 0'); - - this.strip(); - var littleEndian = endian === 'le'; - var res = new ArrayType(reqLength); - - var b, i; - var q = this.clone(); - if (!littleEndian) { - // Assume big-endian - for (i = 0; i < reqLength - byteLength; i++) { - res[i] = 0; - } - - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[reqLength - i - 1] = b; - } - } else { - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[i] = b; - } - - for (; i < reqLength; i++) { - res[i] = 0; - } - } - - return res; - }; - - if (Math.clz32) { - BN.prototype._countBits = function _countBits (w) { - return 32 - Math.clz32(w); - }; - } else { - BN.prototype._countBits = function _countBits (w) { - var t = w; - var r = 0; - if (t >= 0x1000) { - r += 13; - t >>>= 13; - } - if (t >= 0x40) { - r += 7; - t >>>= 7; - } - if (t >= 0x8) { - r += 4; - t >>>= 4; - } - if (t >= 0x02) { - r += 2; - t >>>= 2; - } - return r + t; - }; - } - - BN.prototype._zeroBits = function _zeroBits (w) { - // Short-cut - if (w === 0) return 26; - - var t = w; - var r = 0; - if ((t & 0x1fff) === 0) { - r += 13; - t >>>= 13; - } - if ((t & 0x7f) === 0) { - r += 7; - t >>>= 7; - } - if ((t & 0xf) === 0) { - r += 4; - t >>>= 4; - } - if ((t & 0x3) === 0) { - r += 2; - t >>>= 2; - } - if ((t & 0x1) === 0) { - r++; - } - return r; - }; - - // Return number of used bits in a BN - BN.prototype.bitLength = function bitLength () { - var w = this.words[this.length - 1]; - var hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }; - - function toBitArray (num) { - var w = new Array(num.bitLength()); - - for (var bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0; - var wbit = bit % 26; - - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - - return w; - } - - // Number of trailing zero bits - BN.prototype.zeroBits = function zeroBits () { - if (this.isZero()) return 0; - - var r = 0; - for (var i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - r += b; - if (b !== 26) break; - } - return r; - }; - - BN.prototype.byteLength = function byteLength () { - return Math.ceil(this.bitLength() / 8); - }; - - BN.prototype.toTwos = function toTwos (width) { - if (this.negative !== 0) { - return this.abs().inotn(width).iaddn(1); - } - return this.clone(); - }; - - BN.prototype.fromTwos = function fromTwos (width) { - if (this.testn(width - 1)) { - return this.notn(width).iaddn(1).ineg(); - } - return this.clone(); - }; - - BN.prototype.isNeg = function isNeg () { - return this.negative !== 0; - }; - - // Return negative clone of `this` - BN.prototype.neg = function neg () { - return this.clone().ineg(); - }; - - BN.prototype.ineg = function ineg () { - if (!this.isZero()) { - this.negative ^= 1; - } - - return this; - }; - - // Or `num` with `this` in-place - BN.prototype.iuor = function iuor (num) { - while (this.length < num.length) { - this.words[this.length++] = 0; - } - - for (var i = 0; i < num.length; i++) { - this.words[i] = this.words[i] | num.words[i]; - } - - return this.strip(); - }; - - BN.prototype.ior = function ior (num) { - assert((this.negative | num.negative) === 0); - return this.iuor(num); - }; - - // Or `num` with `this` - BN.prototype.or = function or (num) { - if (this.length > num.length) return this.clone().ior(num); - return num.clone().ior(this); - }; - - BN.prototype.uor = function uor (num) { - if (this.length > num.length) return this.clone().iuor(num); - return num.clone().iuor(this); - }; - - // And `num` with `this` in-place - BN.prototype.iuand = function iuand (num) { - // b = min-length(num, this) - var b; - if (this.length > num.length) { - b = num; - } else { - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = this.words[i] & num.words[i]; - } - - this.length = b.length; - - return this.strip(); - }; - - BN.prototype.iand = function iand (num) { - assert((this.negative | num.negative) === 0); - return this.iuand(num); - }; - - // And `num` with `this` - BN.prototype.and = function and (num) { - if (this.length > num.length) return this.clone().iand(num); - return num.clone().iand(this); - }; - - BN.prototype.uand = function uand (num) { - if (this.length > num.length) return this.clone().iuand(num); - return num.clone().iuand(this); - }; - - // Xor `num` with `this` in-place - BN.prototype.iuxor = function iuxor (num) { - // a.length > b.length - var a; - var b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = a.words[i] ^ b.words[i]; - } - - if (this !== a) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = a.length; - - return this.strip(); - }; - - BN.prototype.ixor = function ixor (num) { - assert((this.negative | num.negative) === 0); - return this.iuxor(num); - }; - - // Xor `num` with `this` - BN.prototype.xor = function xor (num) { - if (this.length > num.length) return this.clone().ixor(num); - return num.clone().ixor(this); - }; - - BN.prototype.uxor = function uxor (num) { - if (this.length > num.length) return this.clone().iuxor(num); - return num.clone().iuxor(this); - }; - - // Not ``this`` with ``width`` bitwidth - BN.prototype.inotn = function inotn (width) { - assert(typeof width === 'number' && width >= 0); - - var bytesNeeded = Math.ceil(width / 26) | 0; - var bitsLeft = width % 26; - - // Extend the buffer with leading zeroes - this._expand(bytesNeeded); - - if (bitsLeft > 0) { - bytesNeeded--; - } - - // Handle complete words - for (var i = 0; i < bytesNeeded; i++) { - this.words[i] = ~this.words[i] & 0x3ffffff; - } - - // Handle the residue - if (bitsLeft > 0) { - this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); - } - - // And remove leading zeroes - return this.strip(); - }; - - BN.prototype.notn = function notn (width) { - return this.clone().inotn(width); - }; - - // Set `bit` of `this` - BN.prototype.setn = function setn (bit, val) { - assert(typeof bit === 'number' && bit >= 0); - - var off = (bit / 26) | 0; - var wbit = bit % 26; - - this._expand(off + 1); - - if (val) { - this.words[off] = this.words[off] | (1 << wbit); - } else { - this.words[off] = this.words[off] & ~(1 << wbit); - } - - return this.strip(); - }; - - // Add `num` to `this` in-place - BN.prototype.iadd = function iadd (num) { - var r; - - // negative + positive - if (this.negative !== 0 && num.negative === 0) { - this.negative = 0; - r = this.isub(num); - this.negative ^= 1; - return this._normSign(); - - // positive + negative - } else if (this.negative === 0 && num.negative !== 0) { - num.negative = 0; - r = this.isub(num); - num.negative = 1; - return r._normSign(); - } - - // a.length > b.length - var a, b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) + (b.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - - this.length = a.length; - if (carry !== 0) { - this.words[this.length] = carry; - this.length++; - // Copy the rest of the words - } else if (a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - return this; - }; - - // Add `num` to `this` - BN.prototype.add = function add (num) { - var res; - if (num.negative !== 0 && this.negative === 0) { - num.negative = 0; - res = this.sub(num); - num.negative ^= 1; - return res; - } else if (num.negative === 0 && this.negative !== 0) { - this.negative = 0; - res = num.sub(this); - this.negative = 1; - return res; - } - - if (this.length > num.length) return this.clone().iadd(num); - - return num.clone().iadd(this); - }; - - // Subtract `num` from `this` in-place - BN.prototype.isub = function isub (num) { - // this - (-num) = this + num - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - num.negative = 1; - return r._normSign(); - - // -this - num = -(this + num) - } else if (this.negative !== 0) { - this.negative = 0; - this.iadd(num); - this.negative = 1; - return this._normSign(); - } - - // At this point both numbers are positive - var cmp = this.cmp(num); - - // Optimization - zeroify - if (cmp === 0) { - this.negative = 0; - this.length = 1; - this.words[0] = 0; - return this; - } - - // a > b - var a, b; - if (cmp > 0) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) - (b.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - - // Copy rest of the words - if (carry === 0 && i < a.length && a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = Math.max(this.length, i); - - if (a !== this) { - this.negative = 1; - } + if (a !== this) { + this.negative = 1; + } return this.strip(); }; @@ -10993,17 +5191,17 @@ function fromByteArray (uint8) { }; })(typeof module === 'undefined' || module, this); -},{"buffer":36}],36:[function(require,module,exports){ +},{"buffer":28}],28:[function(require,module,exports){ -},{}],37:[function(require,module,exports){ -arguments[4][36][0].apply(exports,arguments) -},{"dup":36}],38:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ +arguments[4][28][0].apply(exports,arguments) +},{"dup":28}],30:[function(require,module,exports){ var basex = require('base-x') var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz' module.exports = basex(ALPHABET) -},{"base-x":33}],39:[function(require,module,exports){ +},{"base-x":25}],31:[function(require,module,exports){ (function (Buffer){ /*! * The buffer module from node.js, for the browser. @@ -12784,13 +6982,13 @@ function numberIsNaN (obj) { } }).call(this,require("buffer").Buffer) -},{"base64-js":34,"buffer":39,"ieee754":56}],40:[function(require,module,exports){ +},{"base64-js":26,"buffer":31,"ieee754":48}],32:[function(require,module,exports){ require(".").check("es5"); -},{".":41}],41:[function(require,module,exports){ +},{".":33}],33:[function(require,module,exports){ require("./lib/definitions"); module.exports = require("./lib"); -},{"./lib":44,"./lib/definitions":43}],42:[function(require,module,exports){ +},{"./lib":36,"./lib/definitions":35}],34:[function(require,module,exports){ var CapabilityDetector = function () { this.tests = {}; this.cache = {}; @@ -12820,7 +7018,7 @@ CapabilityDetector.prototype = { }; module.exports = CapabilityDetector; -},{}],43:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ var capability = require("."), define = capability.define, test = capability.test; @@ -12889,7 +7087,7 @@ define("Error.prototype.stack", function () { return e.stack || e.stacktrace; } }); -},{".":44}],44:[function(require,module,exports){ +},{".":36}],36:[function(require,module,exports){ var CapabilityDetector = require("./CapabilityDetector"); var detector = new CapabilityDetector(); @@ -12906,7 +7104,7 @@ capability.check = function (name) { capability.test = capability; module.exports = capability; -},{"./CapabilityDetector":42}],45:[function(require,module,exports){ +},{"./CapabilityDetector":34}],37:[function(require,module,exports){ /*! * depd * Copyright(c) 2015 Douglas Christopher Wilson @@ -12985,9 +7183,9 @@ function wrapproperty (obj, prop, message) { } } -},{}],46:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ module.exports = require("./lib"); -},{"./lib":47}],47:[function(require,module,exports){ +},{"./lib":39}],39:[function(require,module,exports){ require("capability/es5"); var capability = require("capability"); @@ -13001,7 +7199,7 @@ else polyfill = require("./unsupported"); module.exports = polyfill(); -},{"./non-v8/index":51,"./unsupported":53,"./v8":54,"capability":41,"capability/es5":40}],48:[function(require,module,exports){ +},{"./non-v8/index":43,"./unsupported":45,"./v8":46,"capability":33,"capability/es5":32}],40:[function(require,module,exports){ var Class = require("o3").Class, abstractMethod = require("o3").abstractMethod; @@ -13032,7 +7230,7 @@ var Frame = Class(Object, { }); module.exports = Frame; -},{"o3":59}],49:[function(require,module,exports){ +},{"o3":51}],41:[function(require,module,exports){ var Class = require("o3").Class, Frame = require("./Frame"), cache = require("u3").cache; @@ -13071,7 +7269,7 @@ module.exports = { return instance; }) }; -},{"./Frame":48,"o3":59,"u3":81}],50:[function(require,module,exports){ +},{"./Frame":40,"o3":51,"u3":62}],42:[function(require,module,exports){ var Class = require("o3").Class, abstractMethod = require("o3").abstractMethod, eachCombination = require("u3").eachCombination, @@ -13205,7 +7403,7 @@ module.exports = { return instance; }) }; -},{"capability":41,"o3":59,"u3":81}],51:[function(require,module,exports){ +},{"capability":33,"o3":51,"u3":62}],43:[function(require,module,exports){ var FrameStringSource = require("./FrameStringSource"), FrameStringParser = require("./FrameStringParser"), cache = require("u3").cache, @@ -13279,7 +7477,7 @@ module.exports = function () { prepareStackTrace: prepareStackTrace }; }; -},{"../prepareStackTrace":52,"./FrameStringParser":49,"./FrameStringSource":50,"u3":81}],52:[function(require,module,exports){ +},{"../prepareStackTrace":44,"./FrameStringParser":41,"./FrameStringSource":42,"u3":62}],44:[function(require,module,exports){ var prepareStackTrace = function (throwable, frames, warnings) { var string = ""; string += throwable.name || "Error"; @@ -13297,7 +7495,7 @@ var prepareStackTrace = function (throwable, frames, warnings) { }; module.exports = prepareStackTrace; -},{}],53:[function(require,module,exports){ +},{}],45:[function(require,module,exports){ var cache = require("u3").cache, prepareStackTrace = require("./prepareStackTrace"); @@ -13345,3124 +7543,1257 @@ module.exports = function () { }; return { - prepareStackTrace: prepareStackTrace - }; -}; -},{"./prepareStackTrace":52,"u3":81}],54:[function(require,module,exports){ -var prepareStackTrace = require("./prepareStackTrace"); - -module.exports = function () { - Error.getStackTrace = function (throwable) { - return throwable.stack; - }; - - return { - prepareStackTrace: prepareStackTrace - }; -}; -},{"./prepareStackTrace":52}],55:[function(require,module,exports){ -/*! - * http-errors - * Copyright(c) 2014 Jonathan Ong - * Copyright(c) 2016 Douglas Christopher Wilson - * MIT Licensed - */ - -'use strict' - -/** - * Module dependencies. - * @private - */ - -var deprecate = require('depd')('http-errors') -var setPrototypeOf = require('setprototypeof') -var statuses = require('statuses') -var inherits = require('inherits') -var toIdentifier = require('toidentifier') - -/** - * Module exports. - * @public - */ - -module.exports = createError -module.exports.HttpError = createHttpErrorConstructor() - -// Populate exports for all constructors -populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError) - -/** - * Get the code class of a status code. - * @private - */ - -function codeClass (status) { - return Number(String(status).charAt(0) + '00') -} - -/** - * Create a new HTTP Error. - * - * @returns {Error} - * @public - */ - -function createError () { - // so much arity going on ~_~ - var err - var msg - var status = 500 - var props = {} - for (var i = 0; i < arguments.length; i++) { - var arg = arguments[i] - if (arg instanceof Error) { - err = arg - status = err.status || err.statusCode || status - continue - } - switch (typeof arg) { - case 'string': - msg = arg - break - case 'number': - status = arg - if (i !== 0) { - deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)') - } - break - case 'object': - props = arg - break - } - } - - if (typeof status === 'number' && (status < 400 || status >= 600)) { - deprecate('non-error status code; use only 4xx or 5xx status codes') - } - - if (typeof status !== 'number' || - (!statuses[status] && (status < 400 || status >= 600))) { - status = 500 - } - - // constructor - var HttpError = createError[status] || createError[codeClass(status)] - - if (!err) { - // create error - err = HttpError - ? new HttpError(msg) - : new Error(msg || statuses[status]) - Error.captureStackTrace(err, createError) - } - - if (!HttpError || !(err instanceof HttpError) || err.status !== status) { - // add properties to generic error - err.expose = status < 500 - err.status = err.statusCode = status - } - - for (var key in props) { - if (key !== 'status' && key !== 'statusCode') { - err[key] = props[key] - } - } - - return err -} - -/** - * Create HTTP error abstract base class. - * @private - */ - -function createHttpErrorConstructor () { - function HttpError () { - throw new TypeError('cannot construct abstract class') - } - - inherits(HttpError, Error) - - return HttpError -} - -/** - * Create a constructor for a client error. - * @private - */ - -function createClientErrorConstructor (HttpError, name, code) { - var className = name.match(/Error$/) ? name : name + 'Error' - - function ClientError (message) { - // create the error object - var msg = message != null ? message : statuses[code] - var err = new Error(msg) - - // capture a stack trace to the construction point - Error.captureStackTrace(err, ClientError) - - // adjust the [[Prototype]] - setPrototypeOf(err, ClientError.prototype) - - // redefine the error message - Object.defineProperty(err, 'message', { - enumerable: true, - configurable: true, - value: msg, - writable: true - }) - - // redefine the error name - Object.defineProperty(err, 'name', { - enumerable: false, - configurable: true, - value: className, - writable: true - }) - - return err - } - - inherits(ClientError, HttpError) - nameFunc(ClientError, className) - - ClientError.prototype.status = code - ClientError.prototype.statusCode = code - ClientError.prototype.expose = true - - return ClientError -} - -/** - * Create a constructor for a server error. - * @private - */ - -function createServerErrorConstructor (HttpError, name, code) { - var className = name.match(/Error$/) ? name : name + 'Error' - - function ServerError (message) { - // create the error object - var msg = message != null ? message : statuses[code] - var err = new Error(msg) - - // capture a stack trace to the construction point - Error.captureStackTrace(err, ServerError) - - // adjust the [[Prototype]] - setPrototypeOf(err, ServerError.prototype) - - // redefine the error message - Object.defineProperty(err, 'message', { - enumerable: true, - configurable: true, - value: msg, - writable: true - }) - - // redefine the error name - Object.defineProperty(err, 'name', { - enumerable: false, - configurable: true, - value: className, - writable: true - }) - - return err - } - - inherits(ServerError, HttpError) - nameFunc(ServerError, className) - - ServerError.prototype.status = code - ServerError.prototype.statusCode = code - ServerError.prototype.expose = false + prepareStackTrace: prepareStackTrace + }; +}; +},{"./prepareStackTrace":44,"u3":62}],46:[function(require,module,exports){ +var prepareStackTrace = require("./prepareStackTrace"); + +module.exports = function () { + Error.getStackTrace = function (throwable) { + return throwable.stack; + }; + + return { + prepareStackTrace: prepareStackTrace + }; +}; +},{"./prepareStackTrace":44}],47:[function(require,module,exports){ +/*! + * http-errors + * Copyright(c) 2014 Jonathan Ong + * Copyright(c) 2016 Douglas Christopher Wilson + * MIT Licensed + */ - return ServerError -} +'use strict' /** - * Set the name of a function, if possible. + * Module dependencies. * @private */ -function nameFunc (func, name) { - var desc = Object.getOwnPropertyDescriptor(func, 'name') - - if (desc && desc.configurable) { - desc.value = name - Object.defineProperty(func, 'name', desc) - } -} +var deprecate = require('depd')('http-errors') +var setPrototypeOf = require('setprototypeof') +var statuses = require('statuses') +var inherits = require('inherits') +var toIdentifier = require('toidentifier') /** - * Populate the exports object with constructors for every error class. - * @private + * Module exports. + * @public */ -function populateConstructorExports (exports, codes, HttpError) { - codes.forEach(function forEachCode (code) { - var CodeError - var name = toIdentifier(statuses[code]) - - switch (codeClass(code)) { - case 400: - CodeError = createClientErrorConstructor(HttpError, name, code) - break - case 500: - CodeError = createServerErrorConstructor(HttpError, name, code) - break - } - - if (CodeError) { - // export the constructor - exports[code] = CodeError - exports[name] = CodeError - } - }) - - // backwards-compatibility - exports["I'mateapot"] = deprecate.function(exports.ImATeapot, - '"I\'mateapot"; use "ImATeapot" instead') -} - -},{"depd":45,"inherits":57,"setprototypeof":76,"statuses":78,"toidentifier":79}],56:[function(require,module,exports){ -exports.read = function (buffer, offset, isLE, mLen, nBytes) { - var e, m - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var nBits = -7 - var i = isLE ? (nBytes - 1) : 0 - var d = isLE ? -1 : 1 - var s = buffer[offset + i] - - i += d +module.exports = createError +module.exports.HttpError = createHttpErrorConstructor() - e = s & ((1 << (-nBits)) - 1) - s >>= (-nBits) - nBits += eLen - for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} +// Populate exports for all constructors +populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError) - m = e & ((1 << (-nBits)) - 1) - e >>= (-nBits) - nBits += mLen - for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} +/** + * Get the code class of a status code. + * @private + */ - if (e === 0) { - e = 1 - eBias - } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity) - } else { - m = m + Math.pow(2, mLen) - e = e - eBias - } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +function codeClass (status) { + return Number(String(status).charAt(0) + '00') } -exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c - var eLen = (nBytes * 8) - mLen - 1 - var eMax = (1 << eLen) - 1 - var eBias = eMax >> 1 - var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) - var i = isLE ? 0 : (nBytes - 1) - var d = isLE ? 1 : -1 - var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - - value = Math.abs(value) - - if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0 - e = eMax - } else { - e = Math.floor(Math.log(value) / Math.LN2) - if (value * (c = Math.pow(2, -e)) < 1) { - e-- - c *= 2 - } - if (e + eBias >= 1) { - value += rt / c - } else { - value += rt * Math.pow(2, 1 - eBias) - } - if (value * c >= 2) { - e++ - c /= 2 - } +/** + * Create a new HTTP Error. + * + * @returns {Error} + * @public + */ - if (e + eBias >= eMax) { - m = 0 - e = eMax - } else if (e + eBias >= 1) { - m = ((value * c) - 1) * Math.pow(2, mLen) - e = e + eBias - } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) - e = 0 +function createError () { + // so much arity going on ~_~ + var err + var msg + var status = 500 + var props = {} + for (var i = 0; i < arguments.length; i++) { + var arg = arguments[i] + if (arg instanceof Error) { + err = arg + status = err.status || err.statusCode || status + continue } - } - - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - - e = (e << mLen) | m - eLen += mLen - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - - buffer[offset + i - d] |= s * 128 -} - -},{}],57:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true + switch (typeof arg) { + case 'string': + msg = arg + break + case 'number': + status = arg + if (i !== 0) { + deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)') } - }) - } - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor + break + case 'object': + props = arg + break } } -} - -},{}],58:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha256]{@link https://github.com/emn178/js-sha256} - * - * @version 0.9.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2014-2017 - * @license MIT - */ -/*jslint bitwise: true */ -(function () { - 'use strict'; - var ERROR = 'input is invalid type'; - var WINDOW = typeof window === 'object'; - var root = WINDOW ? window : {}; - if (root.JS_SHA256_NO_WINDOW) { - WINDOW = false; + if (typeof status === 'number' && (status < 400 || status >= 600)) { + deprecate('non-error status code; use only 4xx or 5xx status codes') } - var WEB_WORKER = !WINDOW && typeof self === 'object'; - var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; - if (NODE_JS) { - root = global; - } else if (WEB_WORKER) { - root = self; + + if (typeof status !== 'number' || + (!statuses[status] && (status < 400 || status >= 600))) { + status = 500 } - var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === 'object' && module.exports; - var AMD = typeof define === 'function' && define.amd; - var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; - var HEX_CHARS = '0123456789abcdef'.split(''); - var EXTRA = [-2147483648, 8388608, 32768, 128]; - var SHIFT = [24, 16, 8, 0]; - var K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ]; - var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; - var blocks = []; + // constructor + var HttpError = createError[status] || createError[codeClass(status)] - if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { - Array.isArray = function (obj) { - return Object.prototype.toString.call(obj) === '[object Array]'; - }; + if (!err) { + // create error + err = HttpError + ? new HttpError(msg) + : new Error(msg || statuses[status]) + Error.captureStackTrace(err, createError) } - if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { - ArrayBuffer.isView = function (obj) { - return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; - }; + if (!HttpError || !(err instanceof HttpError) || err.status !== status) { + // add properties to generic error + err.expose = status < 500 + err.status = err.statusCode = status } - var createOutputMethod = function (outputType, is224) { - return function (message) { - return new Sha256(is224, true).update(message)[outputType](); - }; - }; - - var createMethod = function (is224) { - var method = createOutputMethod('hex', is224); - if (NODE_JS) { - method = nodeWrap(method, is224); - } - method.create = function () { - return new Sha256(is224); - }; - method.update = function (message) { - return method.create().update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createOutputMethod(type, is224); + for (var key in props) { + if (key !== 'status' && key !== 'statusCode') { + err[key] = props[key] } - return method; - }; + } - var nodeWrap = function (method, is224) { - var crypto = eval("require('crypto')"); - var Buffer = eval("require('buffer').Buffer"); - var algorithm = is224 ? 'sha224' : 'sha256'; - var nodeMethod = function (message) { - if (typeof message === 'string') { - return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); - } else { - if (message === null || message === undefined) { - throw new Error(ERROR); - } else if (message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } - } - if (Array.isArray(message) || ArrayBuffer.isView(message) || - message.constructor === Buffer) { - return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex'); - } else { - return method(message); - } - }; - return nodeMethod; - }; + return err +} - var createHmacOutputMethod = function (outputType, is224) { - return function (key, message) { - return new HmacSha256(key, is224, true).update(message)[outputType](); - }; - }; +/** + * Create HTTP error abstract base class. + * @private + */ - var createHmacMethod = function (is224) { - var method = createHmacOutputMethod('hex', is224); - method.create = function (key) { - return new HmacSha256(key, is224); - }; - method.update = function (key, message) { - return method.create(key).update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createHmacOutputMethod(type, is224); - } - return method; - }; +function createHttpErrorConstructor () { + function HttpError () { + throw new TypeError('cannot construct abstract class') + } - function Sha256(is224, sharedMemory) { - if (sharedMemory) { - blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - this.blocks = blocks; - } else { - this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - } + inherits(HttpError, Error) - if (is224) { - this.h0 = 0xc1059ed8; - this.h1 = 0x367cd507; - this.h2 = 0x3070dd17; - this.h3 = 0xf70e5939; - this.h4 = 0xffc00b31; - this.h5 = 0x68581511; - this.h6 = 0x64f98fa7; - this.h7 = 0xbefa4fa4; - } else { // 256 - this.h0 = 0x6a09e667; - this.h1 = 0xbb67ae85; - this.h2 = 0x3c6ef372; - this.h3 = 0xa54ff53a; - this.h4 = 0x510e527f; - this.h5 = 0x9b05688c; - this.h6 = 0x1f83d9ab; - this.h7 = 0x5be0cd19; - } + return HttpError +} - this.block = this.start = this.bytes = this.hBytes = 0; - this.finalized = this.hashed = false; - this.first = true; - this.is224 = is224; - } +/** + * Create a constructor for a client error. + * @private + */ - Sha256.prototype.update = function (message) { - if (this.finalized) { - return; - } - var notString, type = typeof message; - if (type !== 'string') { - if (type === 'object') { - if (message === null) { - throw new Error(ERROR); - } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } else if (!Array.isArray(message)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { - throw new Error(ERROR); - } - } - } else { - throw new Error(ERROR); - } - notString = true; - } - var code, index = 0, i, length = message.length, blocks = this.blocks; +function createClientErrorConstructor (HttpError, name, code) { + var className = name.match(/Error$/) ? name : name + 'Error' - while (index < length) { - if (this.hashed) { - this.hashed = false; - blocks[0] = this.block; - blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - } + function ClientError (message) { + // create the error object + var msg = message != null ? message : statuses[code] + var err = new Error(msg) - if (notString) { - for (i = this.start; index < length && i < 64; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < 64; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } + // capture a stack trace to the construction point + Error.captureStackTrace(err, ClientError) - this.lastByteIndex = i; - this.bytes += i - this.start; - if (i >= 64) { - this.block = blocks[16]; - this.start = i - 64; - this.hash(); - this.hashed = true; - } else { - this.start = i; - } - } - if (this.bytes > 4294967295) { - this.hBytes += this.bytes / 4294967296 << 0; - this.bytes = this.bytes % 4294967296; - } - return this; - }; + // adjust the [[Prototype]] + setPrototypeOf(err, ClientError.prototype) - Sha256.prototype.finalize = function () { - if (this.finalized) { - return; - } - this.finalized = true; - var blocks = this.blocks, i = this.lastByteIndex; - blocks[16] = this.block; - blocks[i >> 2] |= EXTRA[i & 3]; - this.block = blocks[16]; - if (i >= 56) { - if (!this.hashed) { - this.hash(); - } - blocks[0] = this.block; - blocks[16] = blocks[1] = blocks[2] = blocks[3] = - blocks[4] = blocks[5] = blocks[6] = blocks[7] = - blocks[8] = blocks[9] = blocks[10] = blocks[11] = - blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; - } - blocks[14] = this.hBytes << 3 | this.bytes >>> 29; - blocks[15] = this.bytes << 3; - this.hash(); - }; + // redefine the error message + Object.defineProperty(err, 'message', { + enumerable: true, + configurable: true, + value: msg, + writable: true + }) + + // redefine the error name + Object.defineProperty(err, 'name', { + enumerable: false, + configurable: true, + value: className, + writable: true + }) + + return err + } + + inherits(ClientError, HttpError) + nameFunc(ClientError, className) + + ClientError.prototype.status = code + ClientError.prototype.statusCode = code + ClientError.prototype.expose = true - Sha256.prototype.hash = function () { - var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, - h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; + return ClientError +} - for (j = 16; j < 64; ++j) { - // rightrotate - t1 = blocks[j - 15]; - s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3); - t1 = blocks[j - 2]; - s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10); - blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; - } +/** + * Create a constructor for a server error. + * @private + */ - bc = b & c; - for (j = 0; j < 64; j += 4) { - if (this.first) { - if (this.is224) { - ab = 300032; - t1 = blocks[0] - 1413257819; - h = t1 - 150054599 << 0; - d = t1 + 24177077 << 0; - } else { - ab = 704751109; - t1 = blocks[0] - 210244248; - h = t1 - 1521486534 << 0; - d = t1 + 143694565 << 0; - } - this.first = false; - } else { - s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); - s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); - ab = a & b; - maj = ab ^ (a & c) ^ bc; - ch = (e & f) ^ (~e & g); - t1 = h + s1 + ch + K[j] + blocks[j]; - t2 = s0 + maj; - h = d + t1 << 0; - d = t1 + t2 << 0; - } - s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10)); - s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7)); - da = d & a; - maj = da ^ (d & b) ^ ab; - ch = (h & e) ^ (~h & f); - t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; - t2 = s0 + maj; - g = c + t1 << 0; - c = t1 + t2 << 0; - s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10)); - s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7)); - cd = c & d; - maj = cd ^ (c & a) ^ da; - ch = (g & h) ^ (~g & e); - t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; - t2 = s0 + maj; - f = b + t1 << 0; - b = t1 + t2 << 0; - s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10)); - s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7)); - bc = b & c; - maj = bc ^ (b & d) ^ cd; - ch = (f & g) ^ (~f & h); - t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; - t2 = s0 + maj; - e = a + t1 << 0; - a = t1 + t2 << 0; - } +function createServerErrorConstructor (HttpError, name, code) { + var className = name.match(/Error$/) ? name : name + 'Error' - this.h0 = this.h0 + a << 0; - this.h1 = this.h1 + b << 0; - this.h2 = this.h2 + c << 0; - this.h3 = this.h3 + d << 0; - this.h4 = this.h4 + e << 0; - this.h5 = this.h5 + f << 0; - this.h6 = this.h6 + g << 0; - this.h7 = this.h7 + h << 0; - }; + function ServerError (message) { + // create the error object + var msg = message != null ? message : statuses[code] + var err = new Error(msg) - Sha256.prototype.hex = function () { - this.finalize(); + // capture a stack trace to the construction point + Error.captureStackTrace(err, ServerError) - var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, - h6 = this.h6, h7 = this.h7; + // adjust the [[Prototype]] + setPrototypeOf(err, ServerError.prototype) - var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + - HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + - HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + - HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + - HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + - HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + - HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + - HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + - HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + - HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + - HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + - HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + - HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] + - HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + - HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + - HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + - HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] + - HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] + - HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] + - HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] + - HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] + - HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] + - HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] + - HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] + - HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] + - HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] + - HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] + - HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F]; - if (!this.is224) { - hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] + - HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] + - HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] + - HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F]; - } - return hex; - }; + // redefine the error message + Object.defineProperty(err, 'message', { + enumerable: true, + configurable: true, + value: msg, + writable: true + }) - Sha256.prototype.toString = Sha256.prototype.hex; + // redefine the error name + Object.defineProperty(err, 'name', { + enumerable: false, + configurable: true, + value: className, + writable: true + }) - Sha256.prototype.digest = function () { - this.finalize(); + return err + } - var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, - h6 = this.h6, h7 = this.h7; + inherits(ServerError, HttpError) + nameFunc(ServerError, className) - var arr = [ - (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF, - (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF, - (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF, - (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF, - (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF, - (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF, - (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF - ]; - if (!this.is224) { - arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF); - } - return arr; - }; + ServerError.prototype.status = code + ServerError.prototype.statusCode = code + ServerError.prototype.expose = false - Sha256.prototype.array = Sha256.prototype.digest; + return ServerError +} - Sha256.prototype.arrayBuffer = function () { - this.finalize(); +/** + * Set the name of a function, if possible. + * @private + */ - var buffer = new ArrayBuffer(this.is224 ? 28 : 32); - var dataView = new DataView(buffer); - dataView.setUint32(0, this.h0); - dataView.setUint32(4, this.h1); - dataView.setUint32(8, this.h2); - dataView.setUint32(12, this.h3); - dataView.setUint32(16, this.h4); - dataView.setUint32(20, this.h5); - dataView.setUint32(24, this.h6); - if (!this.is224) { - dataView.setUint32(28, this.h7); - } - return buffer; - }; +function nameFunc (func, name) { + var desc = Object.getOwnPropertyDescriptor(func, 'name') - function HmacSha256(key, is224, sharedMemory) { - var i, type = typeof key; - if (type === 'string') { - var bytes = [], length = key.length, index = 0, code; - for (i = 0; i < length; ++i) { - code = key.charCodeAt(i); - if (code < 0x80) { - bytes[index++] = code; - } else if (code < 0x800) { - bytes[index++] = (0xc0 | (code >> 6)); - bytes[index++] = (0x80 | (code & 0x3f)); - } else if (code < 0xd800 || code >= 0xe000) { - bytes[index++] = (0xe0 | (code >> 12)); - bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); - bytes[index++] = (0x80 | (code & 0x3f)); - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); - bytes[index++] = (0xf0 | (code >> 18)); - bytes[index++] = (0x80 | ((code >> 12) & 0x3f)); - bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); - bytes[index++] = (0x80 | (code & 0x3f)); - } - } - key = bytes; - } else { - if (type === 'object') { - if (key === null) { - throw new Error(ERROR); - } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { - key = new Uint8Array(key); - } else if (!Array.isArray(key)) { - if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { - throw new Error(ERROR); - } - } - } else { - throw new Error(ERROR); - } + if (desc && desc.configurable) { + desc.value = name + Object.defineProperty(func, 'name', desc) + } +} + +/** + * Populate the exports object with constructors for every error class. + * @private + */ + +function populateConstructorExports (exports, codes, HttpError) { + codes.forEach(function forEachCode (code) { + var CodeError + var name = toIdentifier(statuses[code]) + + switch (codeClass(code)) { + case 400: + CodeError = createClientErrorConstructor(HttpError, name, code) + break + case 500: + CodeError = createServerErrorConstructor(HttpError, name, code) + break } - if (key.length > 64) { - key = (new Sha256(is224, true)).update(key).array(); + if (CodeError) { + // export the constructor + exports[code] = CodeError + exports[name] = CodeError } + }) - var oKeyPad = [], iKeyPad = []; - for (i = 0; i < 64; ++i) { - var b = key[i] || 0; - oKeyPad[i] = 0x5c ^ b; - iKeyPad[i] = 0x36 ^ b; - } + // backwards-compatibility + exports["I'mateapot"] = deprecate.function(exports.ImATeapot, + '"I\'mateapot"; use "ImATeapot" instead') +} - Sha256.call(this, is224, sharedMemory); +},{"depd":37,"inherits":49,"setprototypeof":57,"statuses":59,"toidentifier":60}],48:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] - this.update(iKeyPad); - this.oKeyPad = oKeyPad; - this.inner = true; - this.sharedMemory = sharedMemory; - } - HmacSha256.prototype = new Sha256(); + i += d - HmacSha256.prototype.finalize = function () { - Sha256.prototype.finalize.call(this); - if (this.inner) { - this.inner = false; - var innerHash = this.array(); - Sha256.call(this, this.is224, this.sharedMemory); - this.update(this.oKeyPad); - this.update(innerHash); - Sha256.prototype.finalize.call(this); - } - }; + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {} - var exports = createMethod(); - exports.sha256 = exports; - exports.sha224 = createMethod(true); - exports.sha256.hmac = createHmacMethod(); - exports.sha224.hmac = createHmacMethod(true); + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {} - if (COMMON_JS) { - module.exports = exports; + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) } else { - root.sha256 = exports.sha256; - root.sha224 = exports.sha224; - if (AMD) { - define(function () { - return exports; - }); - } + m = m + Math.pow(2, mLen) + e = e - eBias } -})(); + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":63}],59:[function(require,module,exports){ -require("capability/es5"); - -module.exports = require("./lib"); -},{"./lib":62,"capability/es5":40}],60:[function(require,module,exports){ -var Class = function () { - var options = Object.create({ - Source: Object, - config: {}, - buildArgs: [] - }); - - function checkOption(option) { - var key = "config"; - if (option instanceof Function) - key = "Source"; - else if (option instanceof Array) - key = "buildArgs"; - else if (option instanceof Object) - key = "config"; - else - throw new Error("Invalid configuration option."); - if (options.hasOwnProperty(key)) - throw new Error("Duplicated configuration option: " + key + "."); - options[key] = option; - } - - for (var index = 0, length = arguments.length; index < length; ++index) - checkOption(arguments[index]); - - var Source = options.Source, - config = options.config, - buildArgs = options.buildArgs; - - return (Source.extend || Class.extend).call(Source, config, buildArgs); -}; - -Class.factory = function () { - var Source = this; - return function () { - var instance = this; - if (instance.build instanceof Function) - instance.build.apply(instance, arguments); - if (instance.init instanceof Function) - instance.init.apply(instance, arguments); - }; -}; - -Class.extend = function (config, buildArgs) { - var Source = this; - if (!config) - config = {}; - var Subject; - if ((config.prototype instanceof Object) && config.prototype.constructor !== Object) - Subject = config.prototype.constructor; - else if (config.factory instanceof Function) - Subject = config.factory.call(Source); - Subject = (Source.clone || Class.clone).call(Source, Subject, buildArgs); - (Subject.merge || Class.merge).call(Subject, config); - return Subject; -}; - -Class.prototype.extend = function (config, buildArgs) { - var subject = this; - var instance = (subject.clone || Class.prototype.clone).apply(subject, buildArgs); - (instance.merge || Class.prototype.merge).call(instance, config); - return instance; -}; - -Class.clone = function (Subject, buildArgs) { - var Source = this; - if (!(Subject instanceof Function)) - Subject = (Source.factory || Class.factory).call(Source); - Subject.prototype = (Source.prototype.clone || Class.prototype.clone).apply(Source.prototype, buildArgs || []); - Subject.prototype.constructor = Subject; - for (var staticProperty in Source) - if (staticProperty !== "prototype") - Subject[staticProperty] = Source[staticProperty]; - return Subject; -}; - -Class.prototype.clone = function () { - var subject = this; - var instance = Object.create(subject); - if (instance.build instanceof Function) - instance.build.apply(instance, arguments); - return instance; -}; - -Class.merge = function (config) { - var Subject = this; - for (var staticProperty in config) - if (staticProperty !== "prototype") - Subject[staticProperty] = config[staticProperty]; - if (config.prototype instanceof Object) - (Subject.prototype.merge || Class.prototype.merge).call(Subject.prototype, config.prototype); - return Subject; -}; - -Class.prototype.merge = function (config) { - var subject = this; - for (var property in config) - if (property !== "constructor") - subject[property] = config[property]; - return subject; -}; - -Class.absorb = function (config) { - var Subject = this; - for (var staticProperty in config) - if (staticProperty !== "prototype" && (Subject[staticProperty] === undefined || Subject[staticProperty] === Function.prototype[staticProperty])) - Subject[staticProperty] = config[staticProperty]; - if (config.prototype instanceof Object) - (Subject.prototype.absorb || Class.prototype.absorb).call(Subject.prototype, config.prototype); - return Subject; -}; - -Class.prototype.absorb = function (config) { - var subject = this; - for (var property in config) - if (property !== "constructor" && (subject[property] === undefined || subject[property] === Object.prototype[property])) - subject[property] = config[property]; - return subject; -}; - -Class.getAncestor = function () { - var Source = this; - if (Source !== Source.prototype.constructor) - return Source.prototype.constructor; -}; - -Class.newInstance = function () { - var Subject = this; - var instance = Object.create(this.prototype); - Subject.apply(instance, arguments); - return instance; -}; - -module.exports = Class; -},{}],61:[function(require,module,exports){ -module.exports = function () { - throw new Error("Not implemented."); -}; -},{}],62:[function(require,module,exports){ -module.exports = { - Class: require("./Class"), - abstractMethod: require("./abstractMethod") -}; -},{"./Class":60,"./abstractMethod":61}],63:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = (nBytes * 8) - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = ((value * c) - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } -var cachedSetTimeout; -var cachedClearTimeout; + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 } -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); + +},{}],49:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } + +},{}],50:[function(require,module,exports){ +(function (process,global){ +/** + * [js-sha256]{@link https://github.com/emn178/js-sha256} + * + * @version 0.9.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2014-2017 + * @license MIT + */ +/*jslint bitwise: true */ (function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); + 'use strict'; + + var ERROR = 'input is invalid type'; + var WINDOW = typeof window === 'object'; + var root = WINDOW ? window : {}; + if (root.JS_SHA256_NO_WINDOW) { + WINDOW = false; + } + var WEB_WORKER = !WINDOW && typeof self === 'object'; + var NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = global; + } else if (WEB_WORKER) { + root = self; + } + var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && typeof module === 'object' && module.exports; + var AMD = typeof define === 'function' && define.amd; + var ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined'; + var HEX_CHARS = '0123456789abcdef'.split(''); + var EXTRA = [-2147483648, 8388608, 32768, 128]; + var SHIFT = [24, 16, 8, 0]; + var K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + var OUTPUT_TYPES = ['hex', 'array', 'digest', 'arrayBuffer']; + + var blocks = []; + + if (root.JS_SHA256_NO_NODE_JS || !Array.isArray) { + Array.isArray = function (obj) { + return Object.prototype.toString.call(obj) === '[object Array]'; + }; + } + + if (ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) { + ArrayBuffer.isView = function (obj) { + return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer; + }; + } + + var createOutputMethod = function (outputType, is224) { + return function (message) { + return new Sha256(is224, true).update(message)[outputType](); + }; + }; + + var createMethod = function (is224) { + var method = createOutputMethod('hex', is224); + if (NODE_JS) { + method = nodeWrap(method, is224); } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); + method.create = function () { + return new Sha256(is224); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(type, is224); } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); + return method; + }; + + var nodeWrap = function (method, is224) { + var crypto = eval("require('crypto')"); + var Buffer = eval("require('buffer').Buffer"); + var algorithm = is224 ? 'sha224' : 'sha256'; + var nodeMethod = function (message) { + if (typeof message === 'string') { + return crypto.createHash(algorithm).update(message, 'utf8').digest('hex'); + } else { + if (message === null || message === undefined) { + throw new Error(ERROR); + } else if (message.constructor === ArrayBuffer) { + message = new Uint8Array(message); } - } + } + if (Array.isArray(message) || ArrayBuffer.isView(message) || + message.constructor === Buffer) { + return crypto.createHash(algorithm).update(new Buffer(message)).digest('hex'); + } else { + return method(message); + } + }; + return nodeMethod; + }; + var createHmacOutputMethod = function (outputType, is224) { + return function (key, message) { + return new HmacSha256(key, is224, true).update(message)[outputType](); + }; + }; -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); + var createHmacMethod = function (is224) { + var method = createHmacOutputMethod('hex', is224); + method.create = function (key) { + return new HmacSha256(key, is224); + }; + method.update = function (key, message) { + return method.create(key).update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createHmacOutputMethod(type, is224); } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); + return method; + }; + + function Sha256(is224, sharedMemory) { + if (sharedMemory) { + blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + this.blocks = blocks; + } else { + this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); + + if (is224) { + this.h0 = 0xc1059ed8; + this.h1 = 0x367cd507; + this.h2 = 0x3070dd17; + this.h3 = 0xf70e5939; + this.h4 = 0xffc00b31; + this.h5 = 0x68581511; + this.h6 = 0x64f98fa7; + this.h7 = 0xbefa4fa4; + } else { // 256 + this.h0 = 0x6a09e667; + this.h1 = 0xbb67ae85; + this.h2 = 0x3c6ef372; + this.h3 = 0xa54ff53a; + this.h4 = 0x510e527f; + this.h5 = 0x9b05688c; + this.h6 = 0x1f83d9ab; + this.h7 = 0x5be0cd19; + } + + this.block = this.start = this.bytes = this.hBytes = 0; + this.finalized = this.hashed = false; + this.first = true; + this.is224 = is224; + } + + Sha256.prototype.update = function (message) { + if (this.finalized) { + return; + } + var notString, type = typeof message; + if (type !== 'string') { + if (type === 'object') { + if (message === null) { + throw new Error(ERROR); + } else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } else if (!Array.isArray(message)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) { + throw new Error(ERROR); + } } + } else { + throw new Error(ERROR); + } + notString = true; } + var code, index = 0, i, length = message.length, blocks = this.blocks; + while (index < length) { + if (this.hashed) { + this.hashed = false; + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + if (notString) { + for (i = this.start; index < length && i < 64; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < 64; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; + this.lastByteIndex = i; + this.bytes += i - this.start; + if (i >= 64) { + this.block = blocks[16]; + this.start = i - 64; + this.hash(); + this.hashed = true; + } else { + this.start = i; + } } - if (queue.length) { - drainQueue(); + if (this.bytes > 4294967295) { + this.hBytes += this.bytes / 4294967296 << 0; + this.bytes = this.bytes % 4294967296; } -} + return this; + }; -function drainQueue() { - if (draining) { - return; + Sha256.prototype.finalize = function () { + if (this.finalized) { + return; } - var timeout = runTimeout(cleanUpNextTick); - draining = true; + this.finalized = true; + var blocks = this.blocks, i = this.lastByteIndex; + blocks[16] = this.block; + blocks[i >> 2] |= EXTRA[i & 3]; + this.block = blocks[16]; + if (i >= 56) { + if (!this.hashed) { + this.hash(); + } + blocks[0] = this.block; + blocks[16] = blocks[1] = blocks[2] = blocks[3] = + blocks[4] = blocks[5] = blocks[6] = blocks[7] = + blocks[8] = blocks[9] = blocks[10] = blocks[11] = + blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0; + } + blocks[14] = this.hBytes << 3 | this.bytes >>> 29; + blocks[15] = this.bytes << 3; + this.hash(); + }; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; + Sha256.prototype.hash = function () { + var a = this.h0, b = this.h1, c = this.h2, d = this.h3, e = this.h4, f = this.h5, g = this.h6, + h = this.h7, blocks = this.blocks, j, s0, s1, maj, t1, t2, ch, ab, da, cd, bc; + + for (j = 16; j < 64; ++j) { + // rightrotate + t1 = blocks[j - 15]; + s0 = ((t1 >>> 7) | (t1 << 25)) ^ ((t1 >>> 18) | (t1 << 14)) ^ (t1 >>> 3); + t1 = blocks[j - 2]; + s1 = ((t1 >>> 17) | (t1 << 15)) ^ ((t1 >>> 19) | (t1 << 13)) ^ (t1 >>> 10); + blocks[j] = blocks[j - 16] + s0 + blocks[j - 7] + s1 << 0; } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; + bc = b & c; + for (j = 0; j < 64; j += 4) { + if (this.first) { + if (this.is224) { + ab = 300032; + t1 = blocks[0] - 1413257819; + h = t1 - 150054599 << 0; + d = t1 + 24177077 << 0; + } else { + ab = 704751109; + t1 = blocks[0] - 210244248; + h = t1 - 1521486534 << 0; + d = t1 + 143694565 << 0; } + this.first = false; + } else { + s0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10)); + s1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7)); + ab = a & b; + maj = ab ^ (a & c) ^ bc; + ch = (e & f) ^ (~e & g); + t1 = h + s1 + ch + K[j] + blocks[j]; + t2 = s0 + maj; + h = d + t1 << 0; + d = t1 + t2 << 0; + } + s0 = ((d >>> 2) | (d << 30)) ^ ((d >>> 13) | (d << 19)) ^ ((d >>> 22) | (d << 10)); + s1 = ((h >>> 6) | (h << 26)) ^ ((h >>> 11) | (h << 21)) ^ ((h >>> 25) | (h << 7)); + da = d & a; + maj = da ^ (d & b) ^ ab; + ch = (h & e) ^ (~h & f); + t1 = g + s1 + ch + K[j + 1] + blocks[j + 1]; + t2 = s0 + maj; + g = c + t1 << 0; + c = t1 + t2 << 0; + s0 = ((c >>> 2) | (c << 30)) ^ ((c >>> 13) | (c << 19)) ^ ((c >>> 22) | (c << 10)); + s1 = ((g >>> 6) | (g << 26)) ^ ((g >>> 11) | (g << 21)) ^ ((g >>> 25) | (g << 7)); + cd = c & d; + maj = cd ^ (c & a) ^ da; + ch = (g & h) ^ (~g & e); + t1 = f + s1 + ch + K[j + 2] + blocks[j + 2]; + t2 = s0 + maj; + f = b + t1 << 0; + b = t1 + t2 << 0; + s0 = ((b >>> 2) | (b << 30)) ^ ((b >>> 13) | (b << 19)) ^ ((b >>> 22) | (b << 10)); + s1 = ((f >>> 6) | (f << 26)) ^ ((f >>> 11) | (f << 21)) ^ ((f >>> 25) | (f << 7)); + bc = b & c; + maj = bc ^ (b & d) ^ cd; + ch = (f & g) ^ (~f & h); + t1 = e + s1 + ch + K[j + 3] + blocks[j + 3]; + t2 = s0 + maj; + e = a + t1 << 0; + a = t1 + t2 << 0; } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; + this.h0 = this.h0 + a << 0; + this.h1 = this.h1 + b << 0; + this.h2 = this.h2 + c << 0; + this.h3 = this.h3 + d << 0; + this.h4 = this.h4 + e << 0; + this.h5 = this.h5 + f << 0; + this.h6 = this.h6 + g << 0; + this.h7 = this.h7 + h << 0; + }; + + Sha256.prototype.hex = function () { + this.finalize(); + + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, + h6 = this.h6, h7 = this.h7; + + var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] + + HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] + + HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] + + HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] + + HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] + + HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] + + HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] + + HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] + + HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] + + HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] + + HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] + + HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] + + HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] + + HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] + + HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] + + HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] + + HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] + + HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] + + HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] + + HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] + + HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] + + HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] + + HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] + + HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] + + HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] + + HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] + + HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] + + HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F]; + if (!this.is224) { + hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] + + HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] + + HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] + + HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F]; + } + return hex; + }; -function noop() {} + Sha256.prototype.toString = Sha256.prototype.hex; -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; + Sha256.prototype.digest = function () { + this.finalize(); -process.listeners = function (name) { return [] } + var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5, + h6 = this.h6, h7 = this.h7; -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; + var arr = [ + (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF, + (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF, + (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF, + (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF, + (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF, + (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF, + (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF + ]; + if (!this.is224) { + arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF); + } + return arr; + }; -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; + Sha256.prototype.array = Sha256.prototype.digest; -},{}],64:[function(require,module,exports){ -// minimal library entry point. - -"use strict"; -module.exports = require("./src/index-minimal"); + Sha256.prototype.arrayBuffer = function () { + this.finalize(); -},{"./src/index-minimal":65}],65:[function(require,module,exports){ -"use strict"; -var protobuf = exports; - -/** - * Build type, one of `"full"`, `"light"` or `"minimal"`. - * @name build - * @type {string} - * @const - */ -protobuf.build = "minimal"; - -// Serialization -protobuf.Writer = require("./writer"); -protobuf.BufferWriter = require("./writer_buffer"); -protobuf.Reader = require("./reader"); -protobuf.BufferReader = require("./reader_buffer"); - -// Utility -protobuf.util = require("./util/minimal"); -protobuf.rpc = require("./rpc"); -protobuf.roots = require("./roots"); -protobuf.configure = configure; - -/* istanbul ignore next */ -/** - * Reconfigures the library according to the environment. - * @returns {undefined} - */ -function configure() { - protobuf.Reader._configure(protobuf.BufferReader); - protobuf.util._configure(); -} - -// Set up buffer utility according to the environment -protobuf.Writer._configure(protobuf.BufferWriter); -configure(); + var buffer = new ArrayBuffer(this.is224 ? 28 : 32); + var dataView = new DataView(buffer); + dataView.setUint32(0, this.h0); + dataView.setUint32(4, this.h1); + dataView.setUint32(8, this.h2); + dataView.setUint32(12, this.h3); + dataView.setUint32(16, this.h4); + dataView.setUint32(20, this.h5); + dataView.setUint32(24, this.h6); + if (!this.is224) { + dataView.setUint32(28, this.h7); + } + return buffer; + }; -},{"./reader":66,"./reader_buffer":67,"./roots":68,"./rpc":69,"./util/minimal":72,"./writer":73,"./writer_buffer":74}],66:[function(require,module,exports){ -"use strict"; -module.exports = Reader; - -var util = require("./util/minimal"); - -var BufferReader; // cyclic - -var LongBits = util.LongBits, - utf8 = util.utf8; - -/* istanbul ignore next */ -function indexOutOfRange(reader, writeLength) { - return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len); -} - -/** - * Constructs a new reader instance using the specified buffer. - * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`. - * @constructor - * @param {Uint8Array} buffer Buffer to read from - */ -function Reader(buffer) { - - /** - * Read buffer. - * @type {Uint8Array} - */ - this.buf = buffer; - - /** - * Read buffer position. - * @type {number} - */ - this.pos = 0; - - /** - * Read buffer length. - * @type {number} - */ - this.len = buffer.length; -} - -var create_array = typeof Uint8Array !== "undefined" - ? function create_typed_array(buffer) { - if (buffer instanceof Uint8Array || Array.isArray(buffer)) - return new Reader(buffer); - throw Error("illegal buffer"); - } - /* istanbul ignore next */ - : function create_array(buffer) { - if (Array.isArray(buffer)) - return new Reader(buffer); - throw Error("illegal buffer"); - }; - -/** - * Creates a new reader using the specified buffer. - * @function - * @param {Uint8Array|Buffer} buffer Buffer to read from - * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader} - * @throws {Error} If `buffer` is not a valid buffer - */ -Reader.create = util.Buffer - ? function create_buffer_setup(buffer) { - return (Reader.create = function create_buffer(buffer) { - return util.Buffer.isBuffer(buffer) - ? new BufferReader(buffer) - /* istanbul ignore next */ - : create_array(buffer); - })(buffer); - } - /* istanbul ignore next */ - : create_array; - -Reader.prototype._slice = util.Array.prototype.subarray || /* istanbul ignore next */ util.Array.prototype.slice; - -/** - * Reads a varint as an unsigned 32 bit value. - * @function - * @returns {number} Value read - */ -Reader.prototype.uint32 = (function read_uint32_setup() { - var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!) - return function read_uint32() { - value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value; - value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value; - value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value; - value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value; - value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value; - - /* istanbul ignore if */ - if ((this.pos += 5) > this.len) { - this.pos = this.len; - throw indexOutOfRange(this, 10); - } - return value; - }; -})(); - -/** - * Reads a varint as a signed 32 bit value. - * @returns {number} Value read - */ -Reader.prototype.int32 = function read_int32() { - return this.uint32() | 0; -}; - -/** - * Reads a zig-zag encoded varint as a signed 32 bit value. - * @returns {number} Value read - */ -Reader.prototype.sint32 = function read_sint32() { - var value = this.uint32(); - return value >>> 1 ^ -(value & 1) | 0; -}; - -/* eslint-disable no-invalid-this */ - -function readLongVarint() { - // tends to deopt with local vars for octet etc. - var bits = new LongBits(0, 0); - var i = 0; - if (this.len - this.pos > 4) { // fast route (lo) - for (; i < 4; ++i) { - // 1st..4th - bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; - if (this.buf[this.pos++] < 128) - return bits; - } - // 5th - bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0; - bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0; - if (this.buf[this.pos++] < 128) - return bits; - i = 0; - } else { - for (; i < 3; ++i) { - /* istanbul ignore if */ - if (this.pos >= this.len) - throw indexOutOfRange(this); - // 1st..3th - bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0; - if (this.buf[this.pos++] < 128) - return bits; - } - // 4th - bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0; - return bits; - } - if (this.len - this.pos > 4) { // fast route (hi) - for (; i < 5; ++i) { - // 6th..10th - bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; - if (this.buf[this.pos++] < 128) - return bits; - } - } else { - for (; i < 5; ++i) { - /* istanbul ignore if */ - if (this.pos >= this.len) - throw indexOutOfRange(this); - // 6th..10th - bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0; - if (this.buf[this.pos++] < 128) - return bits; - } - } - /* istanbul ignore next */ - throw Error("invalid varint encoding"); -} - -/* eslint-enable no-invalid-this */ - -/** - * Reads a varint as a signed 64 bit value. - * @name Reader#int64 - * @function - * @returns {Long} Value read - */ - -/** - * Reads a varint as an unsigned 64 bit value. - * @name Reader#uint64 - * @function - * @returns {Long} Value read - */ - -/** - * Reads a zig-zag encoded varint as a signed 64 bit value. - * @name Reader#sint64 - * @function - * @returns {Long} Value read - */ - -/** - * Reads a varint as a boolean. - * @returns {boolean} Value read - */ -Reader.prototype.bool = function read_bool() { - return this.uint32() !== 0; -}; - -function readFixed32_end(buf, end) { // note that this uses `end`, not `pos` - return (buf[end - 4] - | buf[end - 3] << 8 - | buf[end - 2] << 16 - | buf[end - 1] << 24) >>> 0; -} - -/** - * Reads fixed 32 bits as an unsigned 32 bit integer. - * @returns {number} Value read - */ -Reader.prototype.fixed32 = function read_fixed32() { - - /* istanbul ignore if */ - if (this.pos + 4 > this.len) - throw indexOutOfRange(this, 4); - - return readFixed32_end(this.buf, this.pos += 4); -}; - -/** - * Reads fixed 32 bits as a signed 32 bit integer. - * @returns {number} Value read - */ -Reader.prototype.sfixed32 = function read_sfixed32() { - - /* istanbul ignore if */ - if (this.pos + 4 > this.len) - throw indexOutOfRange(this, 4); - - return readFixed32_end(this.buf, this.pos += 4) | 0; -}; - -/* eslint-disable no-invalid-this */ - -function readFixed64(/* this: Reader */) { - - /* istanbul ignore if */ - if (this.pos + 8 > this.len) - throw indexOutOfRange(this, 8); - - return new LongBits(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4)); -} - -/* eslint-enable no-invalid-this */ - -/** - * Reads fixed 64 bits. - * @name Reader#fixed64 - * @function - * @returns {Long} Value read - */ - -/** - * Reads zig-zag encoded fixed 64 bits. - * @name Reader#sfixed64 - * @function - * @returns {Long} Value read - */ - -/** - * Reads a float (32 bit) as a number. - * @function - * @returns {number} Value read - */ -Reader.prototype.float = function read_float() { - - /* istanbul ignore if */ - if (this.pos + 4 > this.len) - throw indexOutOfRange(this, 4); - - var value = util.float.readFloatLE(this.buf, this.pos); - this.pos += 4; - return value; -}; - -/** - * Reads a double (64 bit float) as a number. - * @function - * @returns {number} Value read - */ -Reader.prototype.double = function read_double() { - - /* istanbul ignore if */ - if (this.pos + 8 > this.len) - throw indexOutOfRange(this, 4); - - var value = util.float.readDoubleLE(this.buf, this.pos); - this.pos += 8; - return value; -}; - -/** - * Reads a sequence of bytes preceeded by its length as a varint. - * @returns {Uint8Array} Value read - */ -Reader.prototype.bytes = function read_bytes() { - var length = this.uint32(), - start = this.pos, - end = this.pos + length; - - /* istanbul ignore if */ - if (end > this.len) - throw indexOutOfRange(this, length); - - this.pos += length; - if (Array.isArray(this.buf)) // plain array - return this.buf.slice(start, end); - return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1 - ? new this.buf.constructor(0) - : this._slice.call(this.buf, start, end); -}; - -/** - * Reads a string preceeded by its byte length as a varint. - * @returns {string} Value read - */ -Reader.prototype.string = function read_string() { - var bytes = this.bytes(); - return utf8.read(bytes, 0, bytes.length); -}; - -/** - * Skips the specified number of bytes if specified, otherwise skips a varint. - * @param {number} [length] Length if known, otherwise a varint is assumed - * @returns {Reader} `this` - */ -Reader.prototype.skip = function skip(length) { - if (typeof length === "number") { - /* istanbul ignore if */ - if (this.pos + length > this.len) - throw indexOutOfRange(this, length); - this.pos += length; - } else { - do { - /* istanbul ignore if */ - if (this.pos >= this.len) - throw indexOutOfRange(this); - } while (this.buf[this.pos++] & 128); - } - return this; -}; - -/** - * Skips the next element of the specified wire type. - * @param {number} wireType Wire type received - * @returns {Reader} `this` - */ -Reader.prototype.skipType = function(wireType) { - switch (wireType) { - case 0: - this.skip(); - break; - case 1: - this.skip(8); - break; - case 2: - this.skip(this.uint32()); - break; - case 3: - while ((wireType = this.uint32() & 7) !== 4) { - this.skipType(wireType); - } - break; - case 5: - this.skip(4); - break; - - /* istanbul ignore next */ - default: - throw Error("invalid wire type " + wireType + " at offset " + this.pos); - } - return this; -}; - -Reader._configure = function(BufferReader_) { - BufferReader = BufferReader_; - - var fn = util.Long ? "toLong" : /* istanbul ignore next */ "toNumber"; - util.merge(Reader.prototype, { - - int64: function read_int64() { - return readLongVarint.call(this)[fn](false); - }, - - uint64: function read_uint64() { - return readLongVarint.call(this)[fn](true); - }, - - sint64: function read_sint64() { - return readLongVarint.call(this).zzDecode()[fn](false); - }, - - fixed64: function read_fixed64() { - return readFixed64.call(this)[fn](true); - }, - - sfixed64: function read_sfixed64() { - return readFixed64.call(this)[fn](false); - } - - }); -}; + function HmacSha256(key, is224, sharedMemory) { + var i, type = typeof key; + if (type === 'string') { + var bytes = [], length = key.length, index = 0, code; + for (i = 0; i < length; ++i) { + code = key.charCodeAt(i); + if (code < 0x80) { + bytes[index++] = code; + } else if (code < 0x800) { + bytes[index++] = (0xc0 | (code >> 6)); + bytes[index++] = (0x80 | (code & 0x3f)); + } else if (code < 0xd800 || code >= 0xe000) { + bytes[index++] = (0xe0 | (code >> 12)); + bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); + bytes[index++] = (0x80 | (code & 0x3f)); + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff)); + bytes[index++] = (0xf0 | (code >> 18)); + bytes[index++] = (0x80 | ((code >> 12) & 0x3f)); + bytes[index++] = (0x80 | ((code >> 6) & 0x3f)); + bytes[index++] = (0x80 | (code & 0x3f)); + } + } + key = bytes; + } else { + if (type === 'object') { + if (key === null) { + throw new Error(ERROR); + } else if (ARRAY_BUFFER && key.constructor === ArrayBuffer) { + key = new Uint8Array(key); + } else if (!Array.isArray(key)) { + if (!ARRAY_BUFFER || !ArrayBuffer.isView(key)) { + throw new Error(ERROR); + } + } + } else { + throw new Error(ERROR); + } + } -},{"./util/minimal":72}],67:[function(require,module,exports){ -"use strict"; -module.exports = BufferReader; - -// extends Reader -var Reader = require("./reader"); -(BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader; - -var util = require("./util/minimal"); - -/** - * Constructs a new buffer reader instance. - * @classdesc Wire format reader using node buffers. - * @extends Reader - * @constructor - * @param {Buffer} buffer Buffer to read from - */ -function BufferReader(buffer) { - Reader.call(this, buffer); - - /** - * Read buffer. - * @name BufferReader#buf - * @type {Buffer} - */ -} - -/* istanbul ignore else */ -if (util.Buffer) - BufferReader.prototype._slice = util.Buffer.prototype.slice; - -/** - * @override - */ -BufferReader.prototype.string = function read_string_buffer() { - var len = this.uint32(); // modifies pos - return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len)); -}; - -/** - * Reads a sequence of bytes preceeded by its length as a varint. - * @name BufferReader#bytes - * @function - * @returns {Buffer} Value read - */ - -},{"./reader":66,"./util/minimal":72}],68:[function(require,module,exports){ -"use strict"; -module.exports = {}; - -/** - * Named roots. - * This is where pbjs stores generated structures (the option `-r, --root` specifies a name). - * Can also be used manually to make roots available accross modules. - * @name roots - * @type {Object.} - * @example - * // pbjs -r myroot -o compiled.js ... - * - * // in another module: - * require("./compiled.js"); - * - * // in any subsequent module: - * var root = protobuf.roots["myroot"]; - */ - -},{}],69:[function(require,module,exports){ -"use strict"; - -/** - * Streaming RPC helpers. - * @namespace - */ -var rpc = exports; - -/** - * RPC implementation passed to {@link Service#create} performing a service request on network level, i.e. by utilizing http requests or websockets. - * @typedef RPCImpl - * @type {function} - * @param {Method|rpc.ServiceMethod,Message<{}>>} method Reflected or static method being called - * @param {Uint8Array} requestData Request data - * @param {RPCImplCallback} callback Callback function - * @returns {undefined} - * @example - * function rpcImpl(method, requestData, callback) { - * if (protobuf.util.lcFirst(method.name) !== "myMethod") // compatible with static code - * throw Error("no such method"); - * asynchronouslyObtainAResponse(requestData, function(err, responseData) { - * callback(err, responseData); - * }); - * } - */ - -/** - * Node-style callback as used by {@link RPCImpl}. - * @typedef RPCImplCallback - * @type {function} - * @param {Error|null} error Error, if any, otherwise `null` - * @param {Uint8Array|null} [response] Response data or `null` to signal end of stream, if there hasn't been an error - * @returns {undefined} - */ - -rpc.Service = require("./rpc/service"); + if (key.length > 64) { + key = (new Sha256(is224, true)).update(key).array(); + } -},{"./rpc/service":70}],70:[function(require,module,exports){ -"use strict"; -module.exports = Service; - -var util = require("../util/minimal"); - -// Extends EventEmitter -(Service.prototype = Object.create(util.EventEmitter.prototype)).constructor = Service; - -/** - * A service method callback as used by {@link rpc.ServiceMethod|ServiceMethod}. - * - * Differs from {@link RPCImplCallback} in that it is an actual callback of a service method which may not return `response = null`. - * @typedef rpc.ServiceMethodCallback - * @template TRes extends Message - * @type {function} - * @param {Error|null} error Error, if any - * @param {TRes} [response] Response message - * @returns {undefined} - */ - -/** - * A service method part of a {@link rpc.Service} as created by {@link Service.create}. - * @typedef rpc.ServiceMethod - * @template TReq extends Message - * @template TRes extends Message - * @type {function} - * @param {TReq|Properties} request Request message or plain object - * @param {rpc.ServiceMethodCallback} [callback] Node-style callback called with the error, if any, and the response message - * @returns {Promise>} Promise if `callback` has been omitted, otherwise `undefined` - */ - -/** - * Constructs a new RPC service instance. - * @classdesc An RPC service as returned by {@link Service#create}. - * @exports rpc.Service - * @extends util.EventEmitter - * @constructor - * @param {RPCImpl} rpcImpl RPC implementation - * @param {boolean} [requestDelimited=false] Whether requests are length-delimited - * @param {boolean} [responseDelimited=false] Whether responses are length-delimited - */ -function Service(rpcImpl, requestDelimited, responseDelimited) { - - if (typeof rpcImpl !== "function") - throw TypeError("rpcImpl must be a function"); - - util.EventEmitter.call(this); - - /** - * RPC implementation. Becomes `null` once the service is ended. - * @type {RPCImpl|null} - */ - this.rpcImpl = rpcImpl; - - /** - * Whether requests are length-delimited. - * @type {boolean} - */ - this.requestDelimited = Boolean(requestDelimited); - - /** - * Whether responses are length-delimited. - * @type {boolean} - */ - this.responseDelimited = Boolean(responseDelimited); -} - -/** - * Calls a service method through {@link rpc.Service#rpcImpl|rpcImpl}. - * @param {Method|rpc.ServiceMethod} method Reflected or static method - * @param {Constructor} requestCtor Request constructor - * @param {Constructor} responseCtor Response constructor - * @param {TReq|Properties} request Request message or plain object - * @param {rpc.ServiceMethodCallback} callback Service callback - * @returns {undefined} - * @template TReq extends Message - * @template TRes extends Message - */ -Service.prototype.rpcCall = function rpcCall(method, requestCtor, responseCtor, request, callback) { - - if (!request) - throw TypeError("request must be specified"); - - var self = this; - if (!callback) - return util.asPromise(rpcCall, self, method, requestCtor, responseCtor, request); - - if (!self.rpcImpl) { - setTimeout(function() { callback(Error("already ended")); }, 0); - return undefined; - } - - try { - return self.rpcImpl( - method, - requestCtor[self.requestDelimited ? "encodeDelimited" : "encode"](request).finish(), - function rpcCallback(err, response) { - - if (err) { - self.emit("error", err, method); - return callback(err); - } - - if (response === null) { - self.end(/* endedByRPC */ true); - return undefined; - } - - if (!(response instanceof responseCtor)) { - try { - response = responseCtor[self.responseDelimited ? "decodeDelimited" : "decode"](response); - } catch (err) { - self.emit("error", err, method); - return callback(err); - } - } - - self.emit("data", response, method); - return callback(null, response); - } - ); - } catch (err) { - self.emit("error", err, method); - setTimeout(function() { callback(err); }, 0); - return undefined; - } -}; - -/** - * Ends this service and emits the `end` event. - * @param {boolean} [endedByRPC=false] Whether the service has been ended by the RPC implementation. - * @returns {rpc.Service} `this` - */ -Service.prototype.end = function end(endedByRPC) { - if (this.rpcImpl) { - if (!endedByRPC) // signal end to rpcImpl - this.rpcImpl(null, null, null); - this.rpcImpl = null; - this.emit("end").off(); - } - return this; -}; + var oKeyPad = [], iKeyPad = []; + for (i = 0; i < 64; ++i) { + var b = key[i] || 0; + oKeyPad[i] = 0x5c ^ b; + iKeyPad[i] = 0x36 ^ b; + } + + Sha256.call(this, is224, sharedMemory); + + this.update(iKeyPad); + this.oKeyPad = oKeyPad; + this.inner = true; + this.sharedMemory = sharedMemory; + } + HmacSha256.prototype = new Sha256(); -},{"../util/minimal":72}],71:[function(require,module,exports){ -"use strict"; -module.exports = LongBits; - -var util = require("../util/minimal"); - -/** - * Constructs new long bits. - * @classdesc Helper class for working with the low and high bits of a 64 bit value. - * @memberof util - * @constructor - * @param {number} lo Low 32 bits, unsigned - * @param {number} hi High 32 bits, unsigned - */ -function LongBits(lo, hi) { - - // note that the casts below are theoretically unnecessary as of today, but older statically - // generated converter code might still call the ctor with signed 32bits. kept for compat. - - /** - * Low bits. - * @type {number} - */ - this.lo = lo >>> 0; - - /** - * High bits. - * @type {number} - */ - this.hi = hi >>> 0; -} - -/** - * Zero bits. - * @memberof util.LongBits - * @type {util.LongBits} - */ -var zero = LongBits.zero = new LongBits(0, 0); - -zero.toNumber = function() { return 0; }; -zero.zzEncode = zero.zzDecode = function() { return this; }; -zero.length = function() { return 1; }; - -/** - * Zero hash. - * @memberof util.LongBits - * @type {string} - */ -var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0"; - -/** - * Constructs new long bits from the specified number. - * @param {number} value Value - * @returns {util.LongBits} Instance - */ -LongBits.fromNumber = function fromNumber(value) { - if (value === 0) - return zero; - var sign = value < 0; - if (sign) - value = -value; - var lo = value >>> 0, - hi = (value - lo) / 4294967296 >>> 0; - if (sign) { - hi = ~hi >>> 0; - lo = ~lo >>> 0; - if (++lo > 4294967295) { - lo = 0; - if (++hi > 4294967295) - hi = 0; - } - } - return new LongBits(lo, hi); -}; - -/** - * Constructs new long bits from a number, long or string. - * @param {Long|number|string} value Value - * @returns {util.LongBits} Instance - */ -LongBits.from = function from(value) { - if (typeof value === "number") - return LongBits.fromNumber(value); - if (util.isString(value)) { - /* istanbul ignore else */ - if (util.Long) - value = util.Long.fromString(value); - else - return LongBits.fromNumber(parseInt(value, 10)); - } - return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero; -}; - -/** - * Converts this long bits to a possibly unsafe JavaScript number. - * @param {boolean} [unsigned=false] Whether unsigned or not - * @returns {number} Possibly unsafe number - */ -LongBits.prototype.toNumber = function toNumber(unsigned) { - if (!unsigned && this.hi >>> 31) { - var lo = ~this.lo + 1 >>> 0, - hi = ~this.hi >>> 0; - if (!lo) - hi = hi + 1 >>> 0; - return -(lo + hi * 4294967296); - } - return this.lo + this.hi * 4294967296; -}; - -/** - * Converts this long bits to a long. - * @param {boolean} [unsigned=false] Whether unsigned or not - * @returns {Long} Long - */ -LongBits.prototype.toLong = function toLong(unsigned) { - return util.Long - ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned)) - /* istanbul ignore next */ - : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) }; -}; - -var charCodeAt = String.prototype.charCodeAt; - -/** - * Constructs new long bits from the specified 8 characters long hash. - * @param {string} hash Hash - * @returns {util.LongBits} Bits - */ -LongBits.fromHash = function fromHash(hash) { - if (hash === zeroHash) - return zero; - return new LongBits( - ( charCodeAt.call(hash, 0) - | charCodeAt.call(hash, 1) << 8 - | charCodeAt.call(hash, 2) << 16 - | charCodeAt.call(hash, 3) << 24) >>> 0 - , - ( charCodeAt.call(hash, 4) - | charCodeAt.call(hash, 5) << 8 - | charCodeAt.call(hash, 6) << 16 - | charCodeAt.call(hash, 7) << 24) >>> 0 - ); -}; - -/** - * Converts this long bits to a 8 characters long hash. - * @returns {string} Hash - */ -LongBits.prototype.toHash = function toHash() { - return String.fromCharCode( - this.lo & 255, - this.lo >>> 8 & 255, - this.lo >>> 16 & 255, - this.lo >>> 24 , - this.hi & 255, - this.hi >>> 8 & 255, - this.hi >>> 16 & 255, - this.hi >>> 24 - ); -}; - -/** - * Zig-zag encodes this long bits. - * @returns {util.LongBits} `this` - */ -LongBits.prototype.zzEncode = function zzEncode() { - var mask = this.hi >> 31; - this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0; - this.lo = ( this.lo << 1 ^ mask) >>> 0; - return this; -}; - -/** - * Zig-zag decodes this long bits. - * @returns {util.LongBits} `this` - */ -LongBits.prototype.zzDecode = function zzDecode() { - var mask = -(this.lo & 1); - this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0; - this.hi = ( this.hi >>> 1 ^ mask) >>> 0; - return this; -}; - -/** - * Calculates the length of this longbits when encoded as a varint. - * @returns {number} Length - */ -LongBits.prototype.length = function length() { - var part0 = this.lo, - part1 = (this.lo >>> 28 | this.hi << 4) >>> 0, - part2 = this.hi >>> 24; - return part2 === 0 - ? part1 === 0 - ? part0 < 16384 - ? part0 < 128 ? 1 : 2 - : part0 < 2097152 ? 3 : 4 - : part1 < 16384 - ? part1 < 128 ? 5 : 6 - : part1 < 2097152 ? 7 : 8 - : part2 < 128 ? 9 : 10; -}; + HmacSha256.prototype.finalize = function () { + Sha256.prototype.finalize.call(this); + if (this.inner) { + this.inner = false; + var innerHash = this.array(); + Sha256.call(this, this.is224, this.sharedMemory); + this.update(this.oKeyPad); + this.update(innerHash); + Sha256.prototype.finalize.call(this); + } + }; -},{"../util/minimal":72}],72:[function(require,module,exports){ -(function (global){ -"use strict"; -var util = exports; - -// used to return a Promise where callback is omitted -util.asPromise = require("@protobufjs/aspromise"); - -// converts to / from base64 encoded strings -util.base64 = require("@protobufjs/base64"); - -// base class of rpc.Service -util.EventEmitter = require("@protobufjs/eventemitter"); - -// float handling accross browsers -util.float = require("@protobufjs/float"); - -// requires modules optionally and hides the call from bundlers -util.inquire = require("@protobufjs/inquire"); - -// converts to / from utf8 encoded strings -util.utf8 = require("@protobufjs/utf8"); - -// provides a node-like buffer pool in the browser -util.pool = require("@protobufjs/pool"); - -// utility to work with the low and high bits of a 64 bit value -util.LongBits = require("./longbits"); - -// global object reference -util.global = typeof window !== "undefined" && window - || typeof global !== "undefined" && global - || typeof self !== "undefined" && self - || this; // eslint-disable-line no-invalid-this - -/** - * An immuable empty array. - * @memberof util - * @type {Array.<*>} - * @const - */ -util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes - -/** - * An immutable empty object. - * @type {Object} - * @const - */ -util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes - -/** - * Whether running within node or not. - * @memberof util - * @type {boolean} - * @const - */ -util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node); - -/** - * Tests if the specified value is an integer. - * @function - * @param {*} value Value to test - * @returns {boolean} `true` if the value is an integer - */ -util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) { - return typeof value === "number" && isFinite(value) && Math.floor(value) === value; -}; - -/** - * Tests if the specified value is a string. - * @param {*} value Value to test - * @returns {boolean} `true` if the value is a string - */ -util.isString = function isString(value) { - return typeof value === "string" || value instanceof String; -}; - -/** - * Tests if the specified value is a non-null object. - * @param {*} value Value to test - * @returns {boolean} `true` if the value is a non-null object - */ -util.isObject = function isObject(value) { - return value && typeof value === "object"; -}; - -/** - * Checks if a property on a message is considered to be present. - * This is an alias of {@link util.isSet}. - * @function - * @param {Object} obj Plain object or message instance - * @param {string} prop Property name - * @returns {boolean} `true` if considered to be present, otherwise `false` - */ -util.isset = - -/** - * Checks if a property on a message is considered to be present. - * @param {Object} obj Plain object or message instance - * @param {string} prop Property name - * @returns {boolean} `true` if considered to be present, otherwise `false` - */ -util.isSet = function isSet(obj, prop) { - var value = obj[prop]; - if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins - return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0; - return false; -}; - -/** - * Any compatible Buffer instance. - * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings. - * @interface Buffer - * @extends Uint8Array - */ - -/** - * Node's Buffer class if available. - * @type {Constructor} - */ -util.Buffer = (function() { - try { - var Buffer = util.inquire("buffer").Buffer; - // refuse to use non-node buffers if not explicitly assigned (perf reasons): - return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null; - } catch (e) { - /* istanbul ignore next */ - return null; - } -})(); - -// Internal alias of or polyfull for Buffer.from. -util._Buffer_from = null; - -// Internal alias of or polyfill for Buffer.allocUnsafe. -util._Buffer_allocUnsafe = null; - -/** - * Creates a new buffer of whatever type supported by the environment. - * @param {number|number[]} [sizeOrArray=0] Buffer size or number array - * @returns {Uint8Array|Buffer} Buffer - */ -util.newBuffer = function newBuffer(sizeOrArray) { - /* istanbul ignore next */ - return typeof sizeOrArray === "number" - ? util.Buffer - ? util._Buffer_allocUnsafe(sizeOrArray) - : new util.Array(sizeOrArray) - : util.Buffer - ? util._Buffer_from(sizeOrArray) - : typeof Uint8Array === "undefined" - ? sizeOrArray - : new Uint8Array(sizeOrArray); -}; - -/** - * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`. - * @type {Constructor} - */ -util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array; - -/** - * Any compatible Long instance. - * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js. - * @interface Long - * @property {number} low Low bits - * @property {number} high High bits - * @property {boolean} unsigned Whether unsigned or not - */ - -/** - * Long.js's Long class if available. - * @type {Constructor} - */ -util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long - || /* istanbul ignore next */ util.global.Long - || util.inquire("long"); - -/** - * Regular expression used to verify 2 bit (`bool`) map keys. - * @type {RegExp} - * @const - */ -util.key2Re = /^true|false|0|1$/; - -/** - * Regular expression used to verify 32 bit (`int32` etc.) map keys. - * @type {RegExp} - * @const - */ -util.key32Re = /^-?(?:0|[1-9][0-9]*)$/; - -/** - * Regular expression used to verify 64 bit (`int64` etc.) map keys. - * @type {RegExp} - * @const - */ -util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/; - -/** - * Converts a number or long to an 8 characters long hash string. - * @param {Long|number} value Value to convert - * @returns {string} Hash - */ -util.longToHash = function longToHash(value) { - return value - ? util.LongBits.from(value).toHash() - : util.LongBits.zeroHash; -}; - -/** - * Converts an 8 characters long hash string to a long or number. - * @param {string} hash Hash - * @param {boolean} [unsigned=false] Whether unsigned or not - * @returns {Long|number} Original value - */ -util.longFromHash = function longFromHash(hash, unsigned) { - var bits = util.LongBits.fromHash(hash); - if (util.Long) - return util.Long.fromBits(bits.lo, bits.hi, unsigned); - return bits.toNumber(Boolean(unsigned)); -}; - -/** - * Merges the properties of the source object into the destination object. - * @memberof util - * @param {Object.} dst Destination object - * @param {Object.} src Source object - * @param {boolean} [ifNotSet=false] Merges only if the key is not already set - * @returns {Object.} Destination object - */ -function merge(dst, src, ifNotSet) { // used by converters - for (var keys = Object.keys(src), i = 0; i < keys.length; ++i) - if (dst[keys[i]] === undefined || !ifNotSet) - dst[keys[i]] = src[keys[i]]; - return dst; -} - -util.merge = merge; - -/** - * Converts the first character of a string to lower case. - * @param {string} str String to convert - * @returns {string} Converted string - */ -util.lcFirst = function lcFirst(str) { - return str.charAt(0).toLowerCase() + str.substring(1); -}; - -/** - * Creates a custom error constructor. - * @memberof util - * @param {string} name Error name - * @returns {Constructor} Custom error constructor - */ -function newError(name) { - - function CustomError(message, properties) { - - if (!(this instanceof CustomError)) - return new CustomError(message, properties); - - // Error.call(this, message); - // ^ just returns a new error instance because the ctor can be called as a function + var exports = createMethod(); + exports.sha256 = exports; + exports.sha224 = createMethod(true); + exports.sha256.hmac = createHmacMethod(); + exports.sha224.hmac = createHmacMethod(true); + + if (COMMON_JS) { + module.exports = exports; + } else { + root.sha256 = exports.sha256; + root.sha224 = exports.sha224; + if (AMD) { + define(function () { + return exports; + }); + } + } +})(); + +}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"_process":55}],51:[function(require,module,exports){ +require("capability/es5"); - Object.defineProperty(this, "message", { get: function() { return message; } }); +module.exports = require("./lib"); +},{"./lib":54,"capability/es5":32}],52:[function(require,module,exports){ +var Class = function () { + var options = Object.create({ + Source: Object, + config: {}, + buildArgs: [] + }); - /* istanbul ignore next */ - if (Error.captureStackTrace) // node - Error.captureStackTrace(this, CustomError); + function checkOption(option) { + var key = "config"; + if (option instanceof Function) + key = "Source"; + else if (option instanceof Array) + key = "buildArgs"; + else if (option instanceof Object) + key = "config"; else - Object.defineProperty(this, "stack", { value: (new Error()).stack || "" }); - - if (properties) - merge(this, properties); + throw new Error("Invalid configuration option."); + if (options.hasOwnProperty(key)) + throw new Error("Duplicated configuration option: " + key + "."); + options[key] = option; } - (CustomError.prototype = Object.create(Error.prototype)).constructor = CustomError; - - Object.defineProperty(CustomError.prototype, "name", { get: function() { return name; } }); - - CustomError.prototype.toString = function toString() { - return this.name + ": " + this.message; - }; - - return CustomError; -} - -util.newError = newError; - -/** - * Constructs a new protocol error. - * @classdesc Error subclass indicating a protocol specifc error. - * @memberof util - * @extends Error - * @template T extends Message - * @constructor - * @param {string} message Error message - * @param {Object.} [properties] Additional properties - * @example - * try { - * MyMessage.decode(someBuffer); // throws if required fields are missing - * } catch (e) { - * if (e instanceof ProtocolError && e.instance) - * console.log("decoded so far: " + JSON.stringify(e.instance)); - * } - */ -util.ProtocolError = newError("ProtocolError"); - -/** - * So far decoded message instance. - * @name util.ProtocolError#instance - * @type {Message} - */ - -/** - * A OneOf getter as returned by {@link util.oneOfGetter}. - * @typedef OneOfGetter - * @type {function} - * @returns {string|undefined} Set field name, if any - */ - -/** - * Builds a getter for a oneof's present field name. - * @param {string[]} fieldNames Field names - * @returns {OneOfGetter} Unbound getter - */ -util.oneOfGetter = function getOneOf(fieldNames) { - var fieldMap = {}; - for (var i = 0; i < fieldNames.length; ++i) - fieldMap[fieldNames[i]] = 1; - - /** - * @returns {string|undefined} Set field name, if any - * @this Object - * @ignore - */ - return function() { // eslint-disable-line consistent-return - for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i) - if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null) - return keys[i]; - }; -}; - -/** - * A OneOf setter as returned by {@link util.oneOfSetter}. - * @typedef OneOfSetter - * @type {function} - * @param {string|undefined} value Field name - * @returns {undefined} - */ - -/** - * Builds a setter for a oneof's present field name. - * @param {string[]} fieldNames Field names - * @returns {OneOfSetter} Unbound setter - */ -util.oneOfSetter = function setOneOf(fieldNames) { - - /** - * @param {string} name Field name - * @returns {undefined} - * @this Object - * @ignore - */ - return function(name) { - for (var i = 0; i < fieldNames.length; ++i) - if (fieldNames[i] !== name) - delete this[fieldNames[i]]; - }; -}; + for (var index = 0, length = arguments.length; index < length; ++index) + checkOption(arguments[index]); -/** - * Default conversion options used for {@link Message#toJSON} implementations. - * - * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely: - * - * - Longs become strings - * - Enums become string keys - * - Bytes become base64 encoded strings - * - (Sub-)Messages become plain objects - * - Maps become plain objects with all string keys - * - Repeated fields become arrays - * - NaN and Infinity for float and double fields become strings - * - * @type {IConversionOptions} - * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json - */ -util.toJSONOptions = { - longs: String, - enums: String, - bytes: String, - json: true -}; + var Source = options.Source, + config = options.config, + buildArgs = options.buildArgs; -// Sets up buffer utility according to the environment (called in index-minimal) -util._configure = function() { - var Buffer = util.Buffer; - /* istanbul ignore if */ - if (!Buffer) { - util._Buffer_from = util._Buffer_allocUnsafe = null; - return; - } - // because node 4.x buffers are incompatible & immutable - // see: https://github.com/dcodeIO/protobuf.js/pull/665 - util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from || - /* istanbul ignore next */ - function Buffer_from(value, encoding) { - return new Buffer(value, encoding); - }; - util._Buffer_allocUnsafe = Buffer.allocUnsafe || - /* istanbul ignore next */ - function Buffer_allocUnsafe(size) { - return new Buffer(size); - }; + return (Source.extend || Class.extend).call(Source, config, buildArgs); }; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./longbits":71,"@protobufjs/aspromise":26,"@protobufjs/base64":27,"@protobufjs/eventemitter":28,"@protobufjs/float":29,"@protobufjs/inquire":30,"@protobufjs/pool":31,"@protobufjs/utf8":32}],73:[function(require,module,exports){ -"use strict"; -module.exports = Writer; - -var util = require("./util/minimal"); - -var BufferWriter; // cyclic - -var LongBits = util.LongBits, - base64 = util.base64, - utf8 = util.utf8; - -/** - * Constructs a new writer operation instance. - * @classdesc Scheduled writer operation. - * @constructor - * @param {function(*, Uint8Array, number)} fn Function to call - * @param {number} len Value byte length - * @param {*} val Value to write - * @ignore - */ -function Op(fn, len, val) { - - /** - * Function to call. - * @type {function(Uint8Array, number, *)} - */ - this.fn = fn; - - /** - * Value byte length. - * @type {number} - */ - this.len = len; - - /** - * Next operation. - * @type {Writer.Op|undefined} - */ - this.next = undefined; - - /** - * Value to write. - * @type {*} - */ - this.val = val; // type varies -} - -/* istanbul ignore next */ -function noop() {} // eslint-disable-line no-empty-function - -/** - * Constructs a new writer state instance. - * @classdesc Copied writer state. - * @memberof Writer - * @constructor - * @param {Writer} writer Writer to copy state from - * @ignore - */ -function State(writer) { - - /** - * Current head. - * @type {Writer.Op} - */ - this.head = writer.head; - - /** - * Current tail. - * @type {Writer.Op} - */ - this.tail = writer.tail; - - /** - * Current buffer length. - * @type {number} - */ - this.len = writer.len; - - /** - * Next state. - * @type {State|null} - */ - this.next = writer.states; -} -/** - * Constructs a new writer instance. - * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`. - * @constructor - */ -function Writer() { - - /** - * Current length. - * @type {number} - */ - this.len = 0; - - /** - * Operations head. - * @type {Object} - */ - this.head = new Op(noop, 0, 0); - - /** - * Operations tail - * @type {Object} - */ - this.tail = this.head; - - /** - * Linked forked states. - * @type {Object|null} - */ - this.states = null; - - // When a value is written, the writer calculates its byte length and puts it into a linked - // list of operations to perform when finish() is called. This both allows us to allocate - // buffers of the exact required size and reduces the amount of work we have to do compared - // to first calculating over objects and then encoding over objects. In our case, the encoding - // part is just a linked list walk calling operations with already prepared values. -} - -/** - * Creates a new writer. - * @function - * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer} - */ -Writer.create = util.Buffer - ? function create_buffer_setup() { - return (Writer.create = function create_buffer() { - return new BufferWriter(); - })(); - } - /* istanbul ignore next */ - : function create_array() { - return new Writer(); +Class.factory = function () { + var Source = this; + return function () { + var instance = this; + if (instance.build instanceof Function) + instance.build.apply(instance, arguments); + if (instance.init instanceof Function) + instance.init.apply(instance, arguments); }; - -/** - * Allocates a buffer of the specified size. - * @param {number} size Buffer size - * @returns {Uint8Array} Buffer - */ -Writer.alloc = function alloc(size) { - return new util.Array(size); }; -// Use Uint8Array buffer pool in the browser, just like node does with buffers -/* istanbul ignore else */ -if (util.Array !== Array) - Writer.alloc = util.pool(Writer.alloc, util.Array.prototype.subarray); - -/** - * Pushes a new operation to the queue. - * @param {function(Uint8Array, number, *)} fn Function to call - * @param {number} len Value byte length - * @param {number} val Value to write - * @returns {Writer} `this` - * @private - */ -Writer.prototype._push = function push(fn, len, val) { - this.tail = this.tail.next = new Op(fn, len, val); - this.len += len; - return this; -}; - -function writeByte(val, buf, pos) { - buf[pos] = val & 255; -} - -function writeVarint32(val, buf, pos) { - while (val > 127) { - buf[pos++] = val & 127 | 128; - val >>>= 7; - } - buf[pos] = val; -} - -/** - * Constructs a new varint writer operation instance. - * @classdesc Scheduled varint writer operation. - * @extends Op - * @constructor - * @param {number} len Value byte length - * @param {number} val Value to write - * @ignore - */ -function VarintOp(len, val) { - this.len = len; - this.next = undefined; - this.val = val; -} - -VarintOp.prototype = Object.create(Op.prototype); -VarintOp.prototype.fn = writeVarint32; - -/** - * Writes an unsigned 32 bit value as a varint. - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.uint32 = function write_uint32(value) { - // here, the call to this.push has been inlined and a varint specific Op subclass is used. - // uint32 is by far the most frequently used operation and benefits significantly from this. - this.len += (this.tail = this.tail.next = new VarintOp( - (value = value >>> 0) - < 128 ? 1 - : value < 16384 ? 2 - : value < 2097152 ? 3 - : value < 268435456 ? 4 - : 5, - value)).len; - return this; -}; - -/** - * Writes a signed 32 bit value as a varint. - * @function - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.int32 = function write_int32(value) { - return value < 0 - ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec - : this.uint32(value); -}; - -/** - * Writes a 32 bit value as a varint, zig-zag encoded. - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.sint32 = function write_sint32(value) { - return this.uint32((value << 1 ^ value >> 31) >>> 0); -}; - -function writeVarint64(val, buf, pos) { - while (val.hi) { - buf[pos++] = val.lo & 127 | 128; - val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0; - val.hi >>>= 7; - } - while (val.lo > 127) { - buf[pos++] = val.lo & 127 | 128; - val.lo = val.lo >>> 7; - } - buf[pos++] = val.lo; -} - -/** - * Writes an unsigned 64 bit value as a varint. - * @param {Long|number|string} value Value to write - * @returns {Writer} `this` - * @throws {TypeError} If `value` is a string and no long library is present. - */ -Writer.prototype.uint64 = function write_uint64(value) { - var bits = LongBits.from(value); - return this._push(writeVarint64, bits.length(), bits); -}; - -/** - * Writes a signed 64 bit value as a varint. - * @function - * @param {Long|number|string} value Value to write - * @returns {Writer} `this` - * @throws {TypeError} If `value` is a string and no long library is present. - */ -Writer.prototype.int64 = Writer.prototype.uint64; - -/** - * Writes a signed 64 bit value as a varint, zig-zag encoded. - * @param {Long|number|string} value Value to write - * @returns {Writer} `this` - * @throws {TypeError} If `value` is a string and no long library is present. - */ -Writer.prototype.sint64 = function write_sint64(value) { - var bits = LongBits.from(value).zzEncode(); - return this._push(writeVarint64, bits.length(), bits); -}; - -/** - * Writes a boolish value as a varint. - * @param {boolean} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.bool = function write_bool(value) { - return this._push(writeByte, 1, value ? 1 : 0); -}; - -function writeFixed32(val, buf, pos) { - buf[pos ] = val & 255; - buf[pos + 1] = val >>> 8 & 255; - buf[pos + 2] = val >>> 16 & 255; - buf[pos + 3] = val >>> 24; -} - -/** - * Writes an unsigned 32 bit value as fixed 32 bits. - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.fixed32 = function write_fixed32(value) { - return this._push(writeFixed32, 4, value >>> 0); -}; - -/** - * Writes a signed 32 bit value as fixed 32 bits. - * @function - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.sfixed32 = Writer.prototype.fixed32; - -/** - * Writes an unsigned 64 bit value as fixed 64 bits. - * @param {Long|number|string} value Value to write - * @returns {Writer} `this` - * @throws {TypeError} If `value` is a string and no long library is present. - */ -Writer.prototype.fixed64 = function write_fixed64(value) { - var bits = LongBits.from(value); - return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi); -}; - -/** - * Writes a signed 64 bit value as fixed 64 bits. - * @function - * @param {Long|number|string} value Value to write - * @returns {Writer} `this` - * @throws {TypeError} If `value` is a string and no long library is present. - */ -Writer.prototype.sfixed64 = Writer.prototype.fixed64; - -/** - * Writes a float (32 bit). - * @function - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.float = function write_float(value) { - return this._push(util.float.writeFloatLE, 4, value); -}; - -/** - * Writes a double (64 bit float). - * @function - * @param {number} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.double = function write_double(value) { - return this._push(util.float.writeDoubleLE, 8, value); -}; - -var writeBytes = util.Array.prototype.set - ? function writeBytes_set(val, buf, pos) { - buf.set(val, pos); // also works for plain array values - } - /* istanbul ignore next */ - : function writeBytes_for(val, buf, pos) { - for (var i = 0; i < val.length; ++i) - buf[pos + i] = val[i]; - }; - -/** - * Writes a sequence of bytes. - * @param {Uint8Array|string} value Buffer or base64 encoded string to write - * @returns {Writer} `this` - */ -Writer.prototype.bytes = function write_bytes(value) { - var len = value.length >>> 0; - if (!len) - return this._push(writeByte, 1, 0); - if (util.isString(value)) { - var buf = Writer.alloc(len = base64.length(value)); - base64.decode(value, buf, 0); - value = buf; - } - return this.uint32(len)._push(writeBytes, len, value); +Class.extend = function (config, buildArgs) { + var Source = this; + if (!config) + config = {}; + var Subject; + if ((config.prototype instanceof Object) && config.prototype.constructor !== Object) + Subject = config.prototype.constructor; + else if (config.factory instanceof Function) + Subject = config.factory.call(Source); + Subject = (Source.clone || Class.clone).call(Source, Subject, buildArgs); + (Subject.merge || Class.merge).call(Subject, config); + return Subject; }; -/** - * Writes a string. - * @param {string} value Value to write - * @returns {Writer} `this` - */ -Writer.prototype.string = function write_string(value) { - var len = utf8.length(value); - return len - ? this.uint32(len)._push(utf8.write, len, value) - : this._push(writeByte, 1, 0); +Class.prototype.extend = function (config, buildArgs) { + var subject = this; + var instance = (subject.clone || Class.prototype.clone).apply(subject, buildArgs); + (instance.merge || Class.prototype.merge).call(instance, config); + return instance; }; -/** - * Forks this writer's state by pushing it to a stack. - * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state. - * @returns {Writer} `this` - */ -Writer.prototype.fork = function fork() { - this.states = new State(this); - this.head = this.tail = new Op(noop, 0, 0); - this.len = 0; - return this; +Class.clone = function (Subject, buildArgs) { + var Source = this; + if (!(Subject instanceof Function)) + Subject = (Source.factory || Class.factory).call(Source); + Subject.prototype = (Source.prototype.clone || Class.prototype.clone).apply(Source.prototype, buildArgs || []); + Subject.prototype.constructor = Subject; + for (var staticProperty in Source) + if (staticProperty !== "prototype") + Subject[staticProperty] = Source[staticProperty]; + return Subject; }; -/** - * Resets this instance to the last state. - * @returns {Writer} `this` - */ -Writer.prototype.reset = function reset() { - if (this.states) { - this.head = this.states.head; - this.tail = this.states.tail; - this.len = this.states.len; - this.states = this.states.next; - } else { - this.head = this.tail = new Op(noop, 0, 0); - this.len = 0; - } - return this; +Class.prototype.clone = function () { + var subject = this; + var instance = Object.create(subject); + if (instance.build instanceof Function) + instance.build.apply(instance, arguments); + return instance; }; -/** - * Resets to the last state and appends the fork state's current write length as a varint followed by its operations. - * @returns {Writer} `this` - */ -Writer.prototype.ldelim = function ldelim() { - var head = this.head, - tail = this.tail, - len = this.len; - this.reset().uint32(len); - if (len) { - this.tail.next = head.next; // skip noop - this.tail = tail; - this.len += len; - } - return this; +Class.merge = function (config) { + var Subject = this; + for (var staticProperty in config) + if (staticProperty !== "prototype") + Subject[staticProperty] = config[staticProperty]; + if (config.prototype instanceof Object) + (Subject.prototype.merge || Class.prototype.merge).call(Subject.prototype, config.prototype); + return Subject; }; -/** - * Finishes the write operation. - * @returns {Uint8Array} Finished buffer - */ -Writer.prototype.finish = function finish() { - var head = this.head.next, // skip noop - buf = this.constructor.alloc(this.len), - pos = 0; - while (head) { - head.fn(head.val, buf, pos); - pos += head.len; - head = head.next; - } - // this.head = this.tail = null; - return buf; +Class.prototype.merge = function (config) { + var subject = this; + for (var property in config) + if (property !== "constructor") + subject[property] = config[property]; + return subject; }; -Writer._configure = function(BufferWriter_) { - BufferWriter = BufferWriter_; +Class.absorb = function (config) { + var Subject = this; + for (var staticProperty in config) + if (staticProperty !== "prototype" && (Subject[staticProperty] === undefined || Subject[staticProperty] === Function.prototype[staticProperty])) + Subject[staticProperty] = config[staticProperty]; + if (config.prototype instanceof Object) + (Subject.prototype.absorb || Class.prototype.absorb).call(Subject.prototype, config.prototype); + return Subject; }; - -},{"./util/minimal":72}],74:[function(require,module,exports){ -"use strict"; -module.exports = BufferWriter; - -// extends Writer -var Writer = require("./writer"); -(BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter; - -var util = require("./util/minimal"); -var Buffer = util.Buffer; - -/** - * Constructs a new buffer writer instance. - * @classdesc Wire format writer using node buffers. - * @extends Writer - * @constructor - */ -function BufferWriter() { - Writer.call(this); -} - -/** - * Allocates a buffer of the specified size. - * @param {number} size Buffer size - * @returns {Buffer} Buffer - */ -BufferWriter.alloc = function alloc_buffer(size) { - return (BufferWriter.alloc = util._Buffer_allocUnsafe)(size); +Class.prototype.absorb = function (config) { + var subject = this; + for (var property in config) + if (property !== "constructor" && (subject[property] === undefined || subject[property] === Object.prototype[property])) + subject[property] = config[property]; + return subject; }; -var writeBytesBuffer = Buffer && Buffer.prototype instanceof Uint8Array && Buffer.prototype.set.name === "set" - ? function writeBytesBuffer_set(val, buf, pos) { - buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited) - // also works for plain array values - } - /* istanbul ignore next */ - : function writeBytesBuffer_copy(val, buf, pos) { - if (val.copy) // Buffer values - val.copy(buf, pos, 0, val.length); - else for (var i = 0; i < val.length;) // plain array values - buf[pos++] = val[i++]; - }; - -/** - * @override - */ -BufferWriter.prototype.bytes = function write_bytes_buffer(value) { - if (util.isString(value)) - value = util._Buffer_from(value, "base64"); - var len = value.length >>> 0; - this.uint32(len); - if (len) - this._push(writeBytesBuffer, len, value); - return this; +Class.getAncestor = function () { + var Source = this; + if (Source !== Source.prototype.constructor) + return Source.prototype.constructor; }; -function writeStringBuffer(val, buf, pos) { - if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions) - util.utf8.write(val, buf, pos); - else - buf.utf8Write(val, pos); -} - -/** - * @override - */ -BufferWriter.prototype.string = function write_string_buffer(value) { - var len = Buffer.byteLength(value); - this.uint32(len); - if (len) - this._push(writeStringBuffer, len, value); - return this; +Class.newInstance = function () { + var Subject = this; + var instance = Object.create(this.prototype); + Subject.apply(instance, arguments); + return instance; }; - -/** - * Finishes the write operation. - * @name BufferWriter#finish - * @function - * @returns {Buffer} Finished buffer - */ - -},{"./util/minimal":72,"./writer":73}],75:[function(require,module,exports){ +module.exports = Class; +},{}],53:[function(require,module,exports){ +module.exports = function () { + throw new Error("Not implemented."); +}; +},{}],54:[function(require,module,exports){ +module.exports = { + Class: require("./Class"), + abstractMethod: require("./abstractMethod") +}; +},{"./Class":52,"./abstractMethod":53}],55:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; +process.prependListener = noop; +process.prependOnceListener = noop; + +process.listeners = function (name) { return [] } + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + +},{}],56:[function(require,module,exports){ /* eslint-disable node/no-deprecated-api */ var buffer = require('buffer') var Buffer = buffer.Buffer @@ -16526,7 +8857,7 @@ SafeBuffer.allocUnsafeSlow = function (size) { return buffer.SlowBuffer(size) } -},{"buffer":39}],76:[function(require,module,exports){ +},{"buffer":31}],57:[function(require,module,exports){ 'use strict' /* eslint no-proto: 0 */ module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties) @@ -16545,7 +8876,7 @@ function mixinProperties (obj, proto) { return obj } -},{}],77:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ module.exports={ "100": "Continue", "101": "Switching Protocols", @@ -16613,7 +8944,7 @@ module.exports={ "511": "Network Authentication Required" } -},{}],78:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ /*! * statuses * Copyright(c) 2014 Jonathan Ong @@ -16728,7 +9059,7 @@ function status (code) { return n } -},{"./codes.json":77}],79:[function(require,module,exports){ +},{"./codes.json":58}],60:[function(require,module,exports){ /*! * toidentifier * Copyright(c) 2016 Douglas Christopher Wilson @@ -16760,7 +9091,7 @@ function toIdentifier (str) { .replace(/[^ _0-9a-z]/gi, '') } -},{}],80:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ (function(nacl) { 'use strict'; @@ -19139,9 +11470,9 @@ nacl.setPRNG = function(fn) { })(typeof module !== 'undefined' && module.exports ? module.exports : (self.nacl = self.nacl || {})); -},{"crypto":36}],81:[function(require,module,exports){ -arguments[4][46][0].apply(exports,arguments) -},{"./lib":84,"dup":46}],82:[function(require,module,exports){ +},{"crypto":28}],62:[function(require,module,exports){ +arguments[4][38][0].apply(exports,arguments) +},{"./lib":65,"dup":38}],63:[function(require,module,exports){ var cache = function (fn) { var called = false, store; @@ -19163,7 +11494,7 @@ var cache = function (fn) { }; module.exports = cache; -},{}],83:[function(require,module,exports){ +},{}],64:[function(require,module,exports){ module.exports = function eachCombination(alternativesByDimension, callback, combination) { if (!combination) combination = []; @@ -19178,19 +11509,19 @@ module.exports = function eachCombination(alternativesByDimension, callback, com else callback.apply(null, combination); }; -},{}],84:[function(require,module,exports){ +},{}],65:[function(require,module,exports){ module.exports = { cache: require("./cache"), eachCombination: require("./eachCombination") }; -},{"./cache":82,"./eachCombination":83}],85:[function(require,module,exports){ +},{"./cache":63,"./eachCombination":64}],66:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' && typeof arg.copy === 'function' && typeof arg.fill === 'function' && typeof arg.readUInt8 === 'function'; } -},{}],86:[function(require,module,exports){ +},{}],67:[function(require,module,exports){ (function (process,global){ // Copyright Joyent, Inc. and other Node contributors. // @@ -19780,4 +12111,4 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":85,"_process":63,"inherits":57}]},{},[1]); +},{"./support/isBuffer":66,"_process":55,"inherits":49}]},{},[1]); diff --git a/dist/nearlib.min.js b/dist/nearlib.min.js index f4629c9555..e8a88a291a 100644 --- a/dist/nearlib.min.js +++ b/dist/nearlib.min.js @@ -3,30 +3,30 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Buffer; }).call(this,require("buffer").Buffer) -},{"./lib/index":6,"buffer":39,"error-polyfill":46}],2:[function(require,module,exports){ +},{"./lib/index":6,"buffer":31,"error-polyfill":38}],2:[function(require,module,exports){ (function (Buffer){ -"use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const bn_js_1=__importDefault(require("bn.js")),transaction_1=require("./transaction"),provider_1=require("./providers/provider"),serialize_1=require("./utils/serialize"),DEFAULT_FUNC_CALL_AMOUNT=new bn_js_1.default(1e9),TX_STATUS_RETRY_NUMBER=10,TX_STATUS_RETRY_WAIT=500,TX_STATUS_RETRY_WAIT_BACKOFF=1.5;function sleep(t){return new Promise(n=>setTimeout(n,t))}class Account{get ready(){return this._ready||(this._ready=Promise.resolve(this.fetchState()))}constructor(t,n){this.connection=t,this.accountId=n}async fetchState(){const t=await this.connection.provider.query(`account/${this.accountId}`,"");this._state=t,this._state.amount=t.amount,this._state.stake=t.stake}async state(){return await this.ready,this._state}printLogs(t,n){for(const e of n)console.log(`[${t}]: ${e}`)}async retryTxResult(t){let n,e=TX_STATUS_RETRY_WAIT;for(let s=0;st.concat(n.lines),[]);if(t.hasOwnProperty("contractId")?this.printLogs(t.contractId,a):t.hasOwnProperty("originator")&&this.printLogs(t.originator,a),s.status===provider_1.FinalTransactionStatus.Failed&&s.logs){console.warn(a);const t=a.find(t=>t.startsWith("ABORT:"))||a.find(t=>t.startsWith("Runtime error:"))||"";throw new Error(`Transaction ${s.logs[0].hash} failed. ${t}`)}return s}async createAndDeployContract(t,n,e,s){await this.createAccount(t,n,s);const a=new Account(this.connection,t);return await a.ready,await a.deployContract(e),a}async sendMoney(t,n){return await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.sendMoney(this._state.nonce,this.accountId,t,n))}async createAccount(t,n,e){return await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.createAccount(this._state.nonce,this.accountId,t,n,e))}async deployContract(t){return await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.deployContract(this._state.nonce,this.accountId,t))}async functionCall(t,n,e,s){return e||(e={}),await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.functionCall(this._state.nonce,this.accountId,t,n,Buffer.from(JSON.stringify(e)),s||DEFAULT_FUNC_CALL_AMOUNT))}async addKey(t,n,e,s,a){await this.ready,this._state.nonce++;const i=n?transaction_1.createAccessKey(n,e,s,a):null;return this.signAndSendTransaction(transaction_1.addKey(this._state.nonce,this.accountId,t,i))}async deleteKey(t){return await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.deleteKey(this._state.nonce,this.accountId,t))}async stake(t,n){return await this.ready,this._state.nonce++,this.signAndSendTransaction(transaction_1.stake(this._state.nonce,this.accountId,n,t))}async viewFunction(t,n,e){const s=await this.connection.provider.query(`call/${t}/${n}`,serialize_1.base_encode(JSON.stringify(e)));return s.logs&&this.printLogs(t,s.logs),JSON.parse(Buffer.from(s.result).toString())}async getAccountDetails(){const t=await this.connection.provider.query(`access_key/${this.accountId}`,""),n={authorizedApps:[],transactions:[]};return Object.keys(t).forEach(e=>{n.authorizedApps.push({contractId:t[e][1].contract_id,amount:t[e][1].amount,publicKey:serialize_1.base_encode(t[e][0])})}),n}}exports.Account=Account; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const transaction_1=require("./transaction"),provider_1=require("./providers/provider"),serialize_1=require("./utils/serialize"),DEFAULT_FUNC_CALL_AMOUNT=1e6,TX_STATUS_RETRY_NUMBER=10,TX_STATUS_RETRY_WAIT=500,TX_STATUS_RETRY_WAIT_BACKOFF=1.5;function sleep(t){return new Promise(n=>setTimeout(n,t))}class Account{get ready(){return this._ready||(this._ready=Promise.resolve(this.fetchState()))}constructor(t,n){this.connection=t,this.accountId=n}async fetchState(){this._state=await this.connection.provider.query(`account/${this.accountId}`,"");try{const t=await this.connection.signer.getPublicKey(this.accountId,this.connection.networkId);this._accessKey=await this.connection.provider.query(`access_key/${this.accountId}/${t}`,"")}catch{this._accessKey=null}}async state(){return await this.ready,this._state}printLogs(t,n){for(const e of n)console.log(`[${t}]: ${e}`)}async retryTxResult(t){let n,e=TX_STATUS_RETRY_WAIT;for(let s=0;st.concat(n.result.logs),[]);if(this.printLogs(s.transaction.receiverId,i),a.status===provider_1.FinalTransactionStatus.Failed&&i){const t=i.find(t=>t.startsWith("ABORT:"))||i.find(t=>t.startsWith("Runtime error:"))||"";throw new Error(`Transaction ${a.transactions[0].hash} failed. ${t}`)}return a}async createAndDeployContract(t,n,e,s){await this.createAccount(t,n,s);const a=new Account(this.connection,t);return await a.ready,await a.deployContract(e),a}async sendMoney(t,n){return this.signAndSendTransaction(t,[transaction_1.transfer(n)])}async createAccount(t,n,e){const s=transaction_1.fullAccessKey();return this.signAndSendTransaction(t,[transaction_1.createAccount(),transaction_1.transfer(e),transaction_1.addKey(n,s)])}async deployContract(t){return this.signAndSendTransaction(this.accountId,[transaction_1.deployContract(t)])}async functionCall(t,n,e,s,a){return e||(e={}),this.signAndSendTransaction(t,[transaction_1.functionCall(n,Buffer.from(JSON.stringify(e)),s||DEFAULT_FUNC_CALL_AMOUNT,a)])}async addKey(t,n,e,s){let a;return a=null==n?transaction_1.fullAccessKey():transaction_1.functionCallAccessKey(n,e?[e]:[],s),this.signAndSendTransaction(this.accountId,[transaction_1.addKey(t,a)])}async deleteKey(t){return this.signAndSendTransaction(this.accountId,[transaction_1.deleteKey(t)])}async stake(t,n){return this.signAndSendTransaction(this.accountId,[transaction_1.stake(n,t)])}async viewFunction(t,n,e){const s=await this.connection.provider.query(`call/${t}/${n}`,serialize_1.base_encode(JSON.stringify(e)));return s.logs&&this.printLogs(t,s.logs),JSON.parse(Buffer.from(s.result).toString())}async getAccessKeys(){return await this.connection.provider.query(`access_key/${this.accountId}`,"")}async getAccountDetails(){const t=await this.getAccessKeys(),n={authorizedApps:[],transactions:[]};return t.map(t=>{if(void 0!==t.access_key.permission.FunctionCall){const e=t.access_key.permission.FunctionCall;n.authorizedApps.push({contractId:e.receiver_id,amount:e.allowance,publicKey:t.public_key.data})}}),n}}exports.Account=Account; }).call(this,require("buffer").Buffer) -},{"./providers/provider":17,"./transaction":19,"./utils/serialize":23,"bn.js":35,"buffer":39}],3:[function(require,module,exports){ +},{"./providers/provider":16,"./transaction":18,"./utils/serialize":22,"buffer":31}],3:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});class AccountCreator{}exports.AccountCreator=AccountCreator;class LocalAccountCreator extends AccountCreator{constructor(t,c){super(),this.masterAccount=t,this.initialBalance=c}async createAccount(t,c){await this.masterAccount.createAccount(t,c,this.initialBalance)}}exports.LocalAccountCreator=LocalAccountCreator;class UrlAccountCreator extends AccountCreator{constructor(t,c){super(),this.connection=t,this.helperConnection={url:c}}async createAccount(t,c){}}exports.UrlAccountCreator=UrlAccountCreator; },{}],4:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const providers_1=require("./providers"),signer_1=require("./signer");function getProvider(e){switch(e.type){case"JsonRpcProvider":return new providers_1.JsonRpcProvider(e.args.url);default:throw new Error(`Unknown provider type ${e.type}`)}}function getSigner(e,r){switch(r.type){case"InMemorySigner":return new signer_1.InMemorySigner(r.keyStore);default:throw new Error(`Unknown signer type ${r.type}`)}}class Connection{constructor(e,r,n){this.networkId=e,this.provider=r,this.signer=n}static fromConfig(e){const r=getProvider(e.provider),n=getSigner(e.networkId,e.signer);return new Connection(e.networkId,r,n)}}exports.Connection=Connection; -},{"./providers":15,"./signer":18}],5:[function(require,module,exports){ +},{"./providers":14,"./signer":17}],5:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const providers_1=require("./providers");class Contract{constructor(t,e,c){this.account=t,this.contractId=e,c.viewMethods.forEach(t=>{Object.defineProperty(this,t,{writable:!1,value:async function(e){return this.account.viewFunction(this.contractId,t,e||{})}})}),c.changeMethods.forEach(t=>{Object.defineProperty(this,t,{writable:!1,value:async function(e){const c=await this.account.functionCall(this.contractId,t,e||{});return providers_1.getTransactionLastResult(c)}})})}}exports.Contract=Contract; -},{"./providers":15}],6:[function(require,module,exports){ -"use strict";var __importStar=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(null!=r)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(exports,"__esModule",{value:!0});const providers=__importStar(require("./providers"));exports.providers=providers;const utils=__importStar(require("./utils"));exports.utils=utils;const keyStores=__importStar(require("./key_stores"));exports.keyStores=keyStores;const account_1=require("./account");exports.Account=account_1.Account;const accountCreator=__importStar(require("./account_creator"));exports.accountCreator=accountCreator;const connection_1=require("./connection");exports.Connection=connection_1.Connection;const signer_1=require("./signer");exports.Signer=signer_1.Signer,exports.InMemorySigner=signer_1.InMemorySigner;const contract_1=require("./contract");exports.Contract=contract_1.Contract;const key_pair_1=require("./utils/key_pair");exports.KeyPair=key_pair_1.KeyPair;const near_1=require("./near");exports.connect=near_1.connect;const wallet_account_1=require("./wallet-account");exports.WalletAccount=wallet_account_1.WalletAccount; +},{"./providers":14}],6:[function(require,module,exports){ +"use strict";var __importStar=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var t={};if(null!=r)for(var e in r)Object.hasOwnProperty.call(r,e)&&(t[e]=r[e]);return t.default=r,t};Object.defineProperty(exports,"__esModule",{value:!0});const providers=__importStar(require("./providers"));exports.providers=providers;const utils=__importStar(require("./utils"));exports.utils=utils;const keyStores=__importStar(require("./key_stores"));exports.keyStores=keyStores;const transactions=__importStar(require("./transaction"));exports.transactions=transactions;const account_1=require("./account");exports.Account=account_1.Account;const accountCreator=__importStar(require("./account_creator"));exports.accountCreator=accountCreator;const connection_1=require("./connection");exports.Connection=connection_1.Connection;const signer_1=require("./signer");exports.Signer=signer_1.Signer,exports.InMemorySigner=signer_1.InMemorySigner;const contract_1=require("./contract");exports.Contract=contract_1.Contract;const key_pair_1=require("./utils/key_pair");exports.KeyPair=key_pair_1.KeyPair;const near_1=require("./near");exports.connect=near_1.connect;const wallet_account_1=require("./wallet-account");exports.WalletAccount=wallet_account_1.WalletAccount; -},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./near":13,"./providers":15,"./signer":18,"./utils":20,"./utils/key_pair":21,"./wallet-account":25}],7:[function(require,module,exports){ +},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./near":13,"./providers":14,"./signer":17,"./transaction":18,"./utils":19,"./utils/key_pair":20,"./wallet-account":24}],7:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const keystore_1=require("./keystore"),key_pair_1=require("../utils/key_pair"),LOCAL_STORAGE_KEY_PREFIX="nearlib:keystore:";class BrowserLocalStorageKeyStore extends keystore_1.KeyStore{constructor(e=window.localStorage,t=LOCAL_STORAGE_KEY_PREFIX){super(),this.localStorage=e,this.prefix=t}async setKey(e,t,r){this.localStorage.setItem(this.storageKeyForSecretKey(e,t),r.toString())}async getKey(e,t){const r=this.localStorage.getItem(this.storageKeyForSecretKey(e,t));return r?key_pair_1.KeyPair.fromString(r):null}async removeKey(e,t){this.localStorage.removeItem(this.storageKeyForSecretKey(e,t))}async clear(){for(const e of this.storageKeys())e.startsWith(this.prefix)&&this.localStorage.removeItem(e)}async getNetworks(){const e=new Set;for(const t of this.storageKeys())if(t.startsWith(this.prefix)){const r=t.substring(this.prefix.length).split(":");e.add(r[1])}return Array.from(e.values())}async getAccounts(e){const t=new Array;for(const r of this.storageKeys())if(r.startsWith(this.prefix)){const s=r.substring(this.prefix.length).split(":");s[1]===e&&t.push(s[0])}return t}storageKeyForSecretKey(e,t){return`${this.prefix}${t}:${e}`}*storageKeys(){for(let e=0;e{const t=s.split(":");e.add(t[1])}),Array.from(e.values())}async getAccounts(e){const s=new Array;return Object.keys(this.keys).forEach(t=>{const r=t.split(":");r[1]===e&&s.push(r[0])}),s}}exports.InMemoryKeyStore=InMemoryKeyStore; -},{"../utils/key_pair":21,"./keystore":10}],9:[function(require,module,exports){ +},{"../utils/key_pair":20,"./keystore":10}],9:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const keystore_1=require("./keystore");exports.KeyStore=keystore_1.KeyStore;const in_memory_key_store_1=require("./in_memory_key_store");exports.InMemoryKeyStore=in_memory_key_store_1.InMemoryKeyStore;const browser_local_storage_key_store_1=require("./browser_local_storage_key_store");exports.BrowserLocalStorageKeyStore=browser_local_storage_key_store_1.BrowserLocalStorageKeyStore;const unencrypted_file_system_keystore_1=require("./unencrypted_file_system_keystore");exports.UnencryptedFileSystemKeyStore=unencrypted_file_system_keystore_1.UnencryptedFileSystemKeyStore;const merge_key_store_1=require("./merge_key_store");exports.MergeKeyStore=merge_key_store_1.MergeKeyStore; },{"./browser_local_storage_key_store":7,"./in_memory_key_store":8,"./keystore":10,"./merge_key_store":11,"./unencrypted_file_system_keystore":12}],10:[function(require,module,exports){ @@ -38,211 +38,150 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Bu },{"./keystore":10}],12:[function(require,module,exports){ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const fs_1=__importDefault(require("fs")),util_1=require("util"),key_pair_1=require("../utils/key_pair"),keystore_1=require("./keystore"),promisify=e=>e?util_1.promisify(e):()=>{throw new Error("Trying to use unimplemented function. `fs` module not available in web build?")},exists=promisify(fs_1.default.exists),readFile=promisify(fs_1.default.readFile),writeFile=promisify(fs_1.default.writeFile),unlink=promisify(fs_1.default.unlink),readdir=promisify(fs_1.default.readdir),mkdir=promisify(fs_1.default.mkdir);async function loadJsonFile(e){const t=await readFile(e);return JSON.parse(t.toString())}async function ensureDir(e){try{await mkdir(e,{recursive:!0})}catch(e){if("EEXIST"!==e.code)throw e}}exports.loadJsonFile=loadJsonFile;class UnencryptedFileSystemKeyStore extends keystore_1.KeyStore{constructor(e){super(),this.keyDir=e}async setKey(e,t,i){await ensureDir(`${this.keyDir}/${e}`);const r={account_id:t,private_key:i.toString()};await writeFile(this.getKeyFilePath(e,t),JSON.stringify(r))}async getKey(e,t){if(!await exists(this.getKeyFilePath(e,t)))return null;const i=await loadJsonFile(this.getKeyFilePath(e,t));return key_pair_1.KeyPair.fromString(i.private_key)}async removeKey(e,t){await exists(this.getKeyFilePath(e,t))&&await unlink(this.getKeyFilePath(e,t))}async clear(){for(const e of await this.getNetworks())for(const t of await this.getAccounts(e))await this.removeKey(e,t)}getKeyFilePath(e,t){return`${this.keyDir}/${e}/${t}.json`}async getNetworks(){const e=await readdir(this.keyDir),t=new Array;return e.forEach(e=>{t.push(e)}),t}async getAccounts(e){if(!await exists(`${this.keyDir}/${e}`))return[];return(await readdir(`${this.keyDir}/${e}`)).filter(e=>e.endsWith(".json")).map(e=>e.replace(/.json$/,""))}}exports.UnencryptedFileSystemKeyStore=UnencryptedFileSystemKeyStore; -},{"../utils/key_pair":21,"./keystore":10,"fs":37,"util":86}],13:[function(require,module,exports){ +},{"../utils/key_pair":20,"./keystore":10,"fs":29,"util":67}],13:[function(require,module,exports){ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const bn_js_1=__importDefault(require("bn.js")),account_1=require("./account"),connection_1=require("./connection"),contract_1=require("./contract"),unencrypted_file_system_keystore_1=require("./key_stores/unencrypted_file_system_keystore"),key_pair_1=require("./utils/key_pair"),account_creator_1=require("./account_creator"),key_stores_1=require("./key_stores");class Near{constructor(e){this.config=e,this.connection=connection_1.Connection.fromConfig({networkId:e.networkId,provider:{type:"JsonRpcProvider",args:{url:e.nodeUrl}},signer:{type:"InMemorySigner",keyStore:e.deps.keyStore}}),e.masterAccount?this.accountCreator=new account_creator_1.LocalAccountCreator(new account_1.Account(this.connection,e.masterAccount),new bn_js_1.default(e.initialBalance)||new bn_js_1.default(1e12)):e.helperUrl?this.accountCreator=new account_creator_1.UrlAccountCreator(this.connection,e.helperUrl):this.accountCreator=null}async account(e){const t=new account_1.Account(this.connection,e);return await t.state(),t}async createAccount(e,t){if(!this.accountCreator)throw new Error("Must specify account creator, either via masterAccount or helperUrl configuration settings.");return await this.accountCreator.createAccount(e,t),new account_1.Account(this.connection,e)}async loadContract(e,t){console.warn("near.loadContract is deprecated. Use `new nearlib.Contract(yourAccount, contractId, { viewMethods, changeMethods })` instead.");const n=new account_1.Account(this.connection,t.sender);return new contract_1.Contract(n,e,t)}async deployContract(e,t){console.warn("near.deployContract is deprecated. Use `contractAccount.deployContract` or `yourAccount.createAndDeployContract` instead.");const n=new account_1.Account(this.connection,e);return(await n.deployContract(t)).logs[0].hash}async sendTokens(e,t,n){console.warn("near.sendTokens is deprecated. Use `yourAccount.sendMoney` instead.");const c=new account_1.Account(this.connection,t);return(await c.sendMoney(n,e)).logs[0].hash}}async function connect(e){if(e.keyPath&&e.deps&&e.deps.keyStore)try{const t=await unencrypted_file_system_keystore_1.loadJsonFile(e.keyPath);if(t.account_id){const n=new key_pair_1.KeyPairEd25519(t.secret_key),c=new key_stores_1.InMemoryKeyStore;await c.setKey(e.networkId,t.account_id,n),e.masterAccount||(e.masterAccount=t.account_id),e.deps.keyStore=new key_stores_1.MergeKeyStore([e.deps.keyStore,c]),console.log(`Loaded master account ${t.account_id} key from ${e.keyPath} with public key = ${n.getPublicKey()}`)}}catch(t){console.warn(`Failed to load master account key from ${e.keyPath}: ${t}`)}return new Near(e)}exports.Near=Near,exports.connect=connect; -},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./key_stores/unencrypted_file_system_keystore":12,"./utils/key_pair":21,"bn.js":35}],14:[function(require,module,exports){ -"use strict";var $protobuf=require("protobufjs/minimal"),$Reader=$protobuf.Reader,$Writer=$protobuf.Writer,$util=$protobuf.util,$root=$protobuf.roots.default||($protobuf.roots.default={});$root.CreateAccountTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.newAccountId=e.string();break;case 4:o.amount=$root.Uint128.decode(e,e.uint32());break;case 5:o.publicKey=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high)))return"nonce: integer|Long expected";if(null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator))return"originator: string expected";if(null!=e.newAccountId&&e.hasOwnProperty("newAccountId")&&!$util.isString(e.newAccountId))return"newAccountId: string expected";if(null!=e.amount&&e.hasOwnProperty("amount")){var n=$root.Uint128.verify(e.amount);if(n)return"amount."+n}return null!=e.publicKey&&e.hasOwnProperty("publicKey")&&!(e.publicKey&&"number"==typeof e.publicKey.length||$util.isString(e.publicKey))?"publicKey: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.CreateAccountTransaction)return e;var n=new $root.CreateAccountTransaction;if(null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.newAccountId&&(n.newAccountId=String(e.newAccountId)),null!=e.amount){if("object"!=typeof e.amount)throw TypeError(".CreateAccountTransaction.amount: object expected");n.amount=$root.Uint128.fromObject(e.amount)}return null!=e.publicKey&&("string"==typeof e.publicKey?$util.base64.decode(e.publicKey,n.publicKey=$util.newBuffer($util.base64.length(e.publicKey)),0):e.publicKey.length&&(n.publicKey=e.publicKey)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",t.newAccountId="",t.amount=null,n.bytes===String?t.publicKey="":(t.publicKey=[],n.bytes!==Array&&(t.publicKey=$util.newBuffer(t.publicKey)))}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.newAccountId&&e.hasOwnProperty("newAccountId")&&(t.newAccountId=e.newAccountId),null!=e.amount&&e.hasOwnProperty("amount")&&(t.amount=$root.Uint128.toObject(e.amount,n)),null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(t.publicKey=n.bytes===String?$util.base64.encode(e.publicKey,0,e.publicKey.length):n.bytes===Array?Array.prototype.slice.call(e.publicKey):e.publicKey),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.DeployContractTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.contractId=e.string();break;case 3:o.wasmByteArray=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high))?"nonce: integer|Long expected":null!=e.contractId&&e.hasOwnProperty("contractId")&&!$util.isString(e.contractId)?"contractId: string expected":null!=e.wasmByteArray&&e.hasOwnProperty("wasmByteArray")&&!(e.wasmByteArray&&"number"==typeof e.wasmByteArray.length||$util.isString(e.wasmByteArray))?"wasmByteArray: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.DeployContractTransaction)return e;var n=new $root.DeployContractTransaction;return null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.contractId&&(n.contractId=String(e.contractId)),null!=e.wasmByteArray&&("string"==typeof e.wasmByteArray?$util.base64.decode(e.wasmByteArray,n.wasmByteArray=$util.newBuffer($util.base64.length(e.wasmByteArray)),0):e.wasmByteArray.length&&(n.wasmByteArray=e.wasmByteArray)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.contractId="",n.bytes===String?t.wasmByteArray="":(t.wasmByteArray=[],n.bytes!==Array&&(t.wasmByteArray=$util.newBuffer(t.wasmByteArray)))}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.contractId&&e.hasOwnProperty("contractId")&&(t.contractId=e.contractId),null!=e.wasmByteArray&&e.hasOwnProperty("wasmByteArray")&&(t.wasmByteArray=n.bytes===String?$util.base64.encode(e.wasmByteArray,0,e.wasmByteArray.length):n.bytes===Array?Array.prototype.slice.call(e.wasmByteArray):e.wasmByteArray),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.FunctionCallTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.contractId=e.string();break;case 4:o.methodName=e.bytes();break;case 5:o.args=e.bytes();break;case 6:o.amount=$root.Uint128.decode(e,e.uint32());break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high)))return"nonce: integer|Long expected";if(null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator))return"originator: string expected";if(null!=e.contractId&&e.hasOwnProperty("contractId")&&!$util.isString(e.contractId))return"contractId: string expected";if(null!=e.methodName&&e.hasOwnProperty("methodName")&&!(e.methodName&&"number"==typeof e.methodName.length||$util.isString(e.methodName)))return"methodName: buffer expected";if(null!=e.args&&e.hasOwnProperty("args")&&!(e.args&&"number"==typeof e.args.length||$util.isString(e.args)))return"args: buffer expected";if(null!=e.amount&&e.hasOwnProperty("amount")){var n=$root.Uint128.verify(e.amount);if(n)return"amount."+n}return null},e.fromObject=function(e){if(e instanceof $root.FunctionCallTransaction)return e;var n=new $root.FunctionCallTransaction;if(null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.contractId&&(n.contractId=String(e.contractId)),null!=e.methodName&&("string"==typeof e.methodName?$util.base64.decode(e.methodName,n.methodName=$util.newBuffer($util.base64.length(e.methodName)),0):e.methodName.length&&(n.methodName=e.methodName)),null!=e.args&&("string"==typeof e.args?$util.base64.decode(e.args,n.args=$util.newBuffer($util.base64.length(e.args)),0):e.args.length&&(n.args=e.args)),null!=e.amount){if("object"!=typeof e.amount)throw TypeError(".FunctionCallTransaction.amount: object expected");n.amount=$root.Uint128.fromObject(e.amount)}return n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",t.contractId="",n.bytes===String?t.methodName="":(t.methodName=[],n.bytes!==Array&&(t.methodName=$util.newBuffer(t.methodName))),n.bytes===String?t.args="":(t.args=[],n.bytes!==Array&&(t.args=$util.newBuffer(t.args))),t.amount=null}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.contractId&&e.hasOwnProperty("contractId")&&(t.contractId=e.contractId),null!=e.methodName&&e.hasOwnProperty("methodName")&&(t.methodName=n.bytes===String?$util.base64.encode(e.methodName,0,e.methodName.length):n.bytes===Array?Array.prototype.slice.call(e.methodName):e.methodName),null!=e.args&&e.hasOwnProperty("args")&&(t.args=n.bytes===String?$util.base64.encode(e.args,0,e.args.length):n.bytes===Array?Array.prototype.slice.call(e.args):e.args),null!=e.amount&&e.hasOwnProperty("amount")&&(t.amount=$root.Uint128.toObject(e.amount,n)),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.SendMoneyTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.receiver=e.string();break;case 4:o.amount=$root.Uint128.decode(e,e.uint32());break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high)))return"nonce: integer|Long expected";if(null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator))return"originator: string expected";if(null!=e.receiver&&e.hasOwnProperty("receiver")&&!$util.isString(e.receiver))return"receiver: string expected";if(null!=e.amount&&e.hasOwnProperty("amount")){var n=$root.Uint128.verify(e.amount);if(n)return"amount."+n}return null},e.fromObject=function(e){if(e instanceof $root.SendMoneyTransaction)return e;var n=new $root.SendMoneyTransaction;if(null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.receiver&&(n.receiver=String(e.receiver)),null!=e.amount){if("object"!=typeof e.amount)throw TypeError(".SendMoneyTransaction.amount: object expected");n.amount=$root.Uint128.fromObject(e.amount)}return n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",t.receiver="",t.amount=null}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.receiver&&e.hasOwnProperty("receiver")&&(t.receiver=e.receiver),null!=e.amount&&e.hasOwnProperty("amount")&&(t.amount=$root.Uint128.toObject(e.amount,n)),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.StakeTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.amount=$root.Uint128.decode(e,e.uint32());break;case 4:o.publicKey=e.string();break;case 5:o.blsPublicKey=e.string();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high)))return"nonce: integer|Long expected";if(null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator))return"originator: string expected";if(null!=e.amount&&e.hasOwnProperty("amount")){var n=$root.Uint128.verify(e.amount);if(n)return"amount."+n}return null!=e.publicKey&&e.hasOwnProperty("publicKey")&&!$util.isString(e.publicKey)?"publicKey: string expected":null!=e.blsPublicKey&&e.hasOwnProperty("blsPublicKey")&&!$util.isString(e.blsPublicKey)?"blsPublicKey: string expected":null},e.fromObject=function(e){if(e instanceof $root.StakeTransaction)return e;var n=new $root.StakeTransaction;if(null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.amount){if("object"!=typeof e.amount)throw TypeError(".StakeTransaction.amount: object expected");n.amount=$root.Uint128.fromObject(e.amount)}return null!=e.publicKey&&(n.publicKey=String(e.publicKey)),null!=e.blsPublicKey&&(n.blsPublicKey=String(e.blsPublicKey)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",t.amount=null,t.publicKey="",t.blsPublicKey=""}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.amount&&e.hasOwnProperty("amount")&&(t.amount=$root.Uint128.toObject(e.amount,n)),null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(t.publicKey=e.publicKey),null!=e.blsPublicKey&&e.hasOwnProperty("blsPublicKey")&&(t.blsPublicKey=e.blsPublicKey),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.SwapKeyTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.curKey=e.bytes();break;case 4:o.newKey=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high))?"nonce: integer|Long expected":null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator)?"originator: string expected":null!=e.curKey&&e.hasOwnProperty("curKey")&&!(e.curKey&&"number"==typeof e.curKey.length||$util.isString(e.curKey))?"curKey: buffer expected":null!=e.newKey&&e.hasOwnProperty("newKey")&&!(e.newKey&&"number"==typeof e.newKey.length||$util.isString(e.newKey))?"newKey: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.SwapKeyTransaction)return e;var n=new $root.SwapKeyTransaction;return null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.curKey&&("string"==typeof e.curKey?$util.base64.decode(e.curKey,n.curKey=$util.newBuffer($util.base64.length(e.curKey)),0):e.curKey.length&&(n.curKey=e.curKey)),null!=e.newKey&&("string"==typeof e.newKey?$util.base64.decode(e.newKey,n.newKey=$util.newBuffer($util.base64.length(e.newKey)),0):e.newKey.length&&(n.newKey=e.newKey)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",n.bytes===String?t.curKey="":(t.curKey=[],n.bytes!==Array&&(t.curKey=$util.newBuffer(t.curKey))),n.bytes===String?t.newKey="":(t.newKey=[],n.bytes!==Array&&(t.newKey=$util.newBuffer(t.newKey)))}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.curKey&&e.hasOwnProperty("curKey")&&(t.curKey=n.bytes===String?$util.base64.encode(e.curKey,0,e.curKey.length):n.bytes===Array?Array.prototype.slice.call(e.curKey):e.curKey),null!=e.newKey&&e.hasOwnProperty("newKey")&&(t.newKey=n.bytes===String?$util.base64.encode(e.newKey,0,e.newKey.length):n.bytes===Array?Array.prototype.slice.call(e.newKey):e.newKey),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.AddKeyTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.newKey=e.bytes();break;case 4:o.accessKey=$root.AccessKey.decode(e,e.uint32());break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high)))return"nonce: integer|Long expected";if(null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator))return"originator: string expected";if(null!=e.newKey&&e.hasOwnProperty("newKey")&&!(e.newKey&&"number"==typeof e.newKey.length||$util.isString(e.newKey)))return"newKey: buffer expected";if(null!=e.accessKey&&e.hasOwnProperty("accessKey")){var n=$root.AccessKey.verify(e.accessKey);if(n)return"accessKey."+n}return null},e.fromObject=function(e){if(e instanceof $root.AddKeyTransaction)return e;var n=new $root.AddKeyTransaction;if(null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.newKey&&("string"==typeof e.newKey?$util.base64.decode(e.newKey,n.newKey=$util.newBuffer($util.base64.length(e.newKey)),0):e.newKey.length&&(n.newKey=e.newKey)),null!=e.accessKey){if("object"!=typeof e.accessKey)throw TypeError(".AddKeyTransaction.accessKey: object expected");n.accessKey=$root.AccessKey.fromObject(e.accessKey)}return n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",n.bytes===String?t.newKey="":(t.newKey=[],n.bytes!==Array&&(t.newKey=$util.newBuffer(t.newKey))),t.accessKey=null}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.newKey&&e.hasOwnProperty("newKey")&&(t.newKey=n.bytes===String?$util.base64.encode(e.newKey,0,e.newKey.length):n.bytes===Array?Array.prototype.slice.call(e.newKey):e.newKey),null!=e.accessKey&&e.hasOwnProperty("accessKey")&&(t.accessKey=$root.AccessKey.toObject(e.accessKey,n)),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.DeleteKeyTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originator=e.string();break;case 3:o.curKey=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high))?"nonce: integer|Long expected":null!=e.originator&&e.hasOwnProperty("originator")&&!$util.isString(e.originator)?"originator: string expected":null!=e.curKey&&e.hasOwnProperty("curKey")&&!(e.curKey&&"number"==typeof e.curKey.length||$util.isString(e.curKey))?"curKey: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.DeleteKeyTransaction)return e;var n=new $root.DeleteKeyTransaction;return null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originator&&(n.originator=String(e.originator)),null!=e.curKey&&("string"==typeof e.curKey?$util.base64.decode(e.curKey,n.curKey=$util.newBuffer($util.base64.length(e.curKey)),0):e.curKey.length&&(n.curKey=e.curKey)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originator="",n.bytes===String?t.curKey="":(t.curKey=[],n.bytes!==Array&&(t.curKey=$util.newBuffer(t.curKey)))}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originator&&e.hasOwnProperty("originator")&&(t.originator=e.originator),null!=e.curKey&&e.hasOwnProperty("curKey")&&(t.curKey=n.bytes===String?$util.base64.encode(e.curKey,0,e.curKey.length):n.bytes===Array?Array.prototype.slice.call(e.curKey):e.curKey),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.DeleteAccountTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.nonce=e.uint64();break;case 2:o.originatorId=e.string();break;case 3:o.receiverId=e.string();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.nonce&&e.hasOwnProperty("nonce")&&!($util.isInteger(e.nonce)||e.nonce&&$util.isInteger(e.nonce.low)&&$util.isInteger(e.nonce.high))?"nonce: integer|Long expected":null!=e.originatorId&&e.hasOwnProperty("originatorId")&&!$util.isString(e.originatorId)?"originatorId: string expected":null!=e.receiverId&&e.hasOwnProperty("receiverId")&&!$util.isString(e.receiverId)?"receiverId: string expected":null},e.fromObject=function(e){if(e instanceof $root.DeleteAccountTransaction)return e;var n=new $root.DeleteAccountTransaction;return null!=e.nonce&&($util.Long?(n.nonce=$util.Long.fromValue(e.nonce)).unsigned=!0:"string"==typeof e.nonce?n.nonce=parseInt(e.nonce,10):"number"==typeof e.nonce?n.nonce=e.nonce:"object"==typeof e.nonce&&(n.nonce=new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0))),null!=e.originatorId&&(n.originatorId=String(e.originatorId)),null!=e.receiverId&&(n.receiverId=String(e.receiverId)),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults){if($util.Long){var o=new $util.Long(0,0,!0);t.nonce=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.nonce=n.longs===String?"0":0;t.originatorId="",t.receiverId=""}return null!=e.nonce&&e.hasOwnProperty("nonce")&&("number"==typeof e.nonce?t.nonce=n.longs===String?String(e.nonce):e.nonce:t.nonce=n.longs===String?$util.Long.prototype.toString.call(e.nonce):n.longs===Number?new $util.LongBits(e.nonce.low>>>0,e.nonce.high>>>0).toNumber(!0):e.nonce),null!=e.originatorId&&e.hasOwnProperty("originatorId")&&(t.originatorId=e.originatorId),null!=e.receiverId&&e.hasOwnProperty("receiverId")&&(t.receiverId=e.receiverId),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.SignedTransaction=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.signature=e.bytes();break;case 10:o.publicKey=$root.google.protobuf.BytesValue.decode(e,e.uint32());break;case 2:o.createAccount=$root.CreateAccountTransaction.decode(e,e.uint32());break;case 3:o.deployContract=$root.DeployContractTransaction.decode(e,e.uint32());break;case 4:o.functionCall=$root.FunctionCallTransaction.decode(e,e.uint32());break;case 5:o.sendMoney=$root.SendMoneyTransaction.decode(e,e.uint32());break;case 6:o.stake=$root.StakeTransaction.decode(e,e.uint32());break;case 7:o.swapKey=$root.SwapKeyTransaction.decode(e,e.uint32());break;case 8:o.addKey=$root.AddKeyTransaction.decode(e,e.uint32());break;case 9:o.deleteKey=$root.DeleteKeyTransaction.decode(e,e.uint32());break;case 11:o.deleteAccount=$root.DeleteAccountTransaction.decode(e,e.uint32());break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var n={};if(null!=e.signature&&e.hasOwnProperty("signature")&&!(e.signature&&"number"==typeof e.signature.length||$util.isString(e.signature)))return"signature: buffer expected";if(null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(t=$root.google.protobuf.BytesValue.verify(e.publicKey)))return"publicKey."+t;if(null!=e.createAccount&&e.hasOwnProperty("createAccount")&&(n.body=1,t=$root.CreateAccountTransaction.verify(e.createAccount)))return"createAccount."+t;if(null!=e.deployContract&&e.hasOwnProperty("deployContract")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.DeployContractTransaction.verify(e.deployContract))return"deployContract."+t}if(null!=e.functionCall&&e.hasOwnProperty("functionCall")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.FunctionCallTransaction.verify(e.functionCall))return"functionCall."+t}if(null!=e.sendMoney&&e.hasOwnProperty("sendMoney")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.SendMoneyTransaction.verify(e.sendMoney))return"sendMoney."+t}if(null!=e.stake&&e.hasOwnProperty("stake")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.StakeTransaction.verify(e.stake))return"stake."+t}if(null!=e.swapKey&&e.hasOwnProperty("swapKey")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.SwapKeyTransaction.verify(e.swapKey))return"swapKey."+t}if(null!=e.addKey&&e.hasOwnProperty("addKey")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.AddKeyTransaction.verify(e.addKey))return"addKey."+t}if(null!=e.deleteKey&&e.hasOwnProperty("deleteKey")){if(1===n.body)return"body: multiple values";if(n.body=1,t=$root.DeleteKeyTransaction.verify(e.deleteKey))return"deleteKey."+t}if(null!=e.deleteAccount&&e.hasOwnProperty("deleteAccount")){if(1===n.body)return"body: multiple values";var t;if(n.body=1,t=$root.DeleteAccountTransaction.verify(e.deleteAccount))return"deleteAccount."+t}return null},e.fromObject=function(e){if(e instanceof $root.SignedTransaction)return e;var n=new $root.SignedTransaction;if(null!=e.signature&&("string"==typeof e.signature?$util.base64.decode(e.signature,n.signature=$util.newBuffer($util.base64.length(e.signature)),0):e.signature.length&&(n.signature=e.signature)),null!=e.publicKey){if("object"!=typeof e.publicKey)throw TypeError(".SignedTransaction.publicKey: object expected");n.publicKey=$root.google.protobuf.BytesValue.fromObject(e.publicKey)}if(null!=e.createAccount){if("object"!=typeof e.createAccount)throw TypeError(".SignedTransaction.createAccount: object expected");n.createAccount=$root.CreateAccountTransaction.fromObject(e.createAccount)}if(null!=e.deployContract){if("object"!=typeof e.deployContract)throw TypeError(".SignedTransaction.deployContract: object expected");n.deployContract=$root.DeployContractTransaction.fromObject(e.deployContract)}if(null!=e.functionCall){if("object"!=typeof e.functionCall)throw TypeError(".SignedTransaction.functionCall: object expected");n.functionCall=$root.FunctionCallTransaction.fromObject(e.functionCall)}if(null!=e.sendMoney){if("object"!=typeof e.sendMoney)throw TypeError(".SignedTransaction.sendMoney: object expected");n.sendMoney=$root.SendMoneyTransaction.fromObject(e.sendMoney)}if(null!=e.stake){if("object"!=typeof e.stake)throw TypeError(".SignedTransaction.stake: object expected");n.stake=$root.StakeTransaction.fromObject(e.stake)}if(null!=e.swapKey){if("object"!=typeof e.swapKey)throw TypeError(".SignedTransaction.swapKey: object expected");n.swapKey=$root.SwapKeyTransaction.fromObject(e.swapKey)}if(null!=e.addKey){if("object"!=typeof e.addKey)throw TypeError(".SignedTransaction.addKey: object expected");n.addKey=$root.AddKeyTransaction.fromObject(e.addKey)}if(null!=e.deleteKey){if("object"!=typeof e.deleteKey)throw TypeError(".SignedTransaction.deleteKey: object expected");n.deleteKey=$root.DeleteKeyTransaction.fromObject(e.deleteKey)}if(null!=e.deleteAccount){if("object"!=typeof e.deleteAccount)throw TypeError(".SignedTransaction.deleteAccount: object expected");n.deleteAccount=$root.DeleteAccountTransaction.fromObject(e.deleteAccount)}return n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(n.bytes===String?t.signature="":(t.signature=[],n.bytes!==Array&&(t.signature=$util.newBuffer(t.signature))),t.publicKey=null),null!=e.signature&&e.hasOwnProperty("signature")&&(t.signature=n.bytes===String?$util.base64.encode(e.signature,0,e.signature.length):n.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.createAccount&&e.hasOwnProperty("createAccount")&&(t.createAccount=$root.CreateAccountTransaction.toObject(e.createAccount,n),n.oneofs&&(t.body="createAccount")),null!=e.deployContract&&e.hasOwnProperty("deployContract")&&(t.deployContract=$root.DeployContractTransaction.toObject(e.deployContract,n),n.oneofs&&(t.body="deployContract")),null!=e.functionCall&&e.hasOwnProperty("functionCall")&&(t.functionCall=$root.FunctionCallTransaction.toObject(e.functionCall,n),n.oneofs&&(t.body="functionCall")),null!=e.sendMoney&&e.hasOwnProperty("sendMoney")&&(t.sendMoney=$root.SendMoneyTransaction.toObject(e.sendMoney,n),n.oneofs&&(t.body="sendMoney")),null!=e.stake&&e.hasOwnProperty("stake")&&(t.stake=$root.StakeTransaction.toObject(e.stake,n),n.oneofs&&(t.body="stake")),null!=e.swapKey&&e.hasOwnProperty("swapKey")&&(t.swapKey=$root.SwapKeyTransaction.toObject(e.swapKey,n),n.oneofs&&(t.body="swapKey")),null!=e.addKey&&e.hasOwnProperty("addKey")&&(t.addKey=$root.AddKeyTransaction.toObject(e.addKey,n),n.oneofs&&(t.body="addKey")),null!=e.deleteKey&&e.hasOwnProperty("deleteKey")&&(t.deleteKey=$root.DeleteKeyTransaction.toObject(e.deleteKey,n),n.oneofs&&(t.body="deleteKey")),null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(t.publicKey=$root.google.protobuf.BytesValue.toObject(e.publicKey,n)),null!=e.deleteAccount&&e.hasOwnProperty("deleteAccount")&&(t.deleteAccount=$root.DeleteAccountTransaction.toObject(e.deleteAccount,n),n.oneofs&&(t.body="deleteAccount")),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.google=function(){var e,n={};return n.protobuf=((e={}).DoubleValue=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.double();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&"number"!=typeof e.value?"value: number expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.DoubleValue)return e;var n=new $root.google.protobuf.DoubleValue;return null!=e.value&&(n.value=Number(e.value)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=0),null!=e.value&&e.hasOwnProperty("value")&&(t.value=n.json&&!isFinite(e.value)?String(e.value):e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.FloatValue=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.float();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&"number"!=typeof e.value?"value: number expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.FloatValue)return e;var n=new $root.google.protobuf.FloatValue;return null!=e.value&&(n.value=Number(e.value)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=0),null!=e.value&&e.hasOwnProperty("value")&&(t.value=n.json&&!isFinite(e.value)?String(e.value):e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.Int64Value=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.int64();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!($util.isInteger(e.value)||e.value&&$util.isInteger(e.value.low)&&$util.isInteger(e.value.high))?"value: integer|Long expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.Int64Value)return e;var n=new $root.google.protobuf.Int64Value;return null!=e.value&&($util.Long?(n.value=$util.Long.fromValue(e.value)).unsigned=!1:"string"==typeof e.value?n.value=parseInt(e.value,10):"number"==typeof e.value?n.value=e.value:"object"==typeof e.value&&(n.value=new $util.LongBits(e.value.low>>>0,e.value.high>>>0).toNumber())),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults)if($util.Long){var o=new $util.Long(0,0,!1);t.value=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.value=n.longs===String?"0":0;return null!=e.value&&e.hasOwnProperty("value")&&("number"==typeof e.value?t.value=n.longs===String?String(e.value):e.value:t.value=n.longs===String?$util.Long.prototype.toString.call(e.value):n.longs===Number?new $util.LongBits(e.value.low>>>0,e.value.high>>>0).toNumber():e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.UInt64Value=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.uint64();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!($util.isInteger(e.value)||e.value&&$util.isInteger(e.value.low)&&$util.isInteger(e.value.high))?"value: integer|Long expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.UInt64Value)return e;var n=new $root.google.protobuf.UInt64Value;return null!=e.value&&($util.Long?(n.value=$util.Long.fromValue(e.value)).unsigned=!0:"string"==typeof e.value?n.value=parseInt(e.value,10):"number"==typeof e.value?n.value=e.value:"object"==typeof e.value&&(n.value=new $util.LongBits(e.value.low>>>0,e.value.high>>>0).toNumber(!0))),n},e.toObject=function(e,n){n||(n={});var t={};if(n.defaults)if($util.Long){var o=new $util.Long(0,0,!0);t.value=n.longs===String?o.toString():n.longs===Number?o.toNumber():o}else t.value=n.longs===String?"0":0;return null!=e.value&&e.hasOwnProperty("value")&&("number"==typeof e.value?t.value=n.longs===String?String(e.value):e.value:t.value=n.longs===String?$util.Long.prototype.toString.call(e.value):n.longs===Number?new $util.LongBits(e.value.low>>>0,e.value.high>>>0).toNumber(!0):e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.Int32Value=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.int32();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!$util.isInteger(e.value)?"value: integer expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.Int32Value)return e;var n=new $root.google.protobuf.Int32Value;return null!=e.value&&(n.value=0|e.value),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=0),null!=e.value&&e.hasOwnProperty("value")&&(t.value=e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.UInt32Value=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.uint32();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!$util.isInteger(e.value)?"value: integer expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.UInt32Value)return e;var n=new $root.google.protobuf.UInt32Value;return null!=e.value&&(n.value=e.value>>>0),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=0),null!=e.value&&e.hasOwnProperty("value")&&(t.value=e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.BoolValue=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.bool();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&"boolean"!=typeof e.value?"value: boolean expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.BoolValue)return e;var n=new $root.google.protobuf.BoolValue;return null!=e.value&&(n.value=Boolean(e.value)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=!1),null!=e.value&&e.hasOwnProperty("value")&&(t.value=e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.StringValue=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.string();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!$util.isString(e.value)?"value: string expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.StringValue)return e;var n=new $root.google.protobuf.StringValue;return null!=e.value&&(n.value=String(e.value)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.value=""),null!=e.value&&e.hasOwnProperty("value")&&(t.value=e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e.BytesValue=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.value=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!(e.value&&"number"==typeof e.value.length||$util.isString(e.value))?"value: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.google.protobuf.BytesValue)return e;var n=new $root.google.protobuf.BytesValue;return null!=e.value&&("string"==typeof e.value?$util.base64.decode(e.value,n.value=$util.newBuffer($util.base64.length(e.value)),0):e.value.length&&(n.value=e.value)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(n.bytes===String?t.value="":(t.value=[],n.bytes!==Array&&(t.value=$util.newBuffer(t.value)))),null!=e.value&&e.hasOwnProperty("value")&&(t.value=n.bytes===String?$util.base64.encode(e.value,0,e.value.length):n.bytes===Array?Array.prototype.slice.call(e.value):e.value),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),e),n}(),$root.AccessKey=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.amount=$root.Uint128.decode(e,e.uint32());break;case 2:o.balanceOwner=$root.google.protobuf.StringValue.decode(e,e.uint32());break;case 3:o.contractId=$root.google.protobuf.StringValue.decode(e,e.uint32());break;case 4:o.methodName=$root.google.protobuf.BytesValue.decode(e,e.uint32());break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";var n;if(null!=e.amount&&e.hasOwnProperty("amount")&&(n=$root.Uint128.verify(e.amount)))return"amount."+n;if(null!=e.balanceOwner&&e.hasOwnProperty("balanceOwner")&&(n=$root.google.protobuf.StringValue.verify(e.balanceOwner)))return"balanceOwner."+n;if(null!=e.contractId&&e.hasOwnProperty("contractId")&&(n=$root.google.protobuf.StringValue.verify(e.contractId)))return"contractId."+n;if(null!=e.methodName&&e.hasOwnProperty("methodName")&&(n=$root.google.protobuf.BytesValue.verify(e.methodName)))return"methodName."+n;return null},e.fromObject=function(e){if(e instanceof $root.AccessKey)return e;var n=new $root.AccessKey;if(null!=e.amount){if("object"!=typeof e.amount)throw TypeError(".AccessKey.amount: object expected");n.amount=$root.Uint128.fromObject(e.amount)}if(null!=e.balanceOwner){if("object"!=typeof e.balanceOwner)throw TypeError(".AccessKey.balanceOwner: object expected");n.balanceOwner=$root.google.protobuf.StringValue.fromObject(e.balanceOwner)}if(null!=e.contractId){if("object"!=typeof e.contractId)throw TypeError(".AccessKey.contractId: object expected");n.contractId=$root.google.protobuf.StringValue.fromObject(e.contractId)}if(null!=e.methodName){if("object"!=typeof e.methodName)throw TypeError(".AccessKey.methodName: object expected");n.methodName=$root.google.protobuf.BytesValue.fromObject(e.methodName)}return n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(t.amount=null,t.balanceOwner=null,t.contractId=null,t.methodName=null),null!=e.amount&&e.hasOwnProperty("amount")&&(t.amount=$root.Uint128.toObject(e.amount,n)),null!=e.balanceOwner&&e.hasOwnProperty("balanceOwner")&&(t.balanceOwner=$root.google.protobuf.StringValue.toObject(e.balanceOwner,n)),null!=e.contractId&&e.hasOwnProperty("contractId")&&(t.contractId=$root.google.protobuf.StringValue.toObject(e.contractId,n)),null!=e.methodName&&e.hasOwnProperty("methodName")&&(t.methodName=$root.google.protobuf.BytesValue.toObject(e.methodName,n)),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),$root.Uint128=function(){function e(e){if(e)for(var n=Object.keys(e),t=0;t>>3){case 1:o.number=e.bytes();break;default:e.skipType(7&r)}}return o},e.decodeDelimited=function(e){return e instanceof $Reader||(e=new $Reader(e)),this.decode(e,e.uint32())},e.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.number&&e.hasOwnProperty("number")&&!(e.number&&"number"==typeof e.number.length||$util.isString(e.number))?"number: buffer expected":null},e.fromObject=function(e){if(e instanceof $root.Uint128)return e;var n=new $root.Uint128;return null!=e.number&&("string"==typeof e.number?$util.base64.decode(e.number,n.number=$util.newBuffer($util.base64.length(e.number)),0):e.number.length&&(n.number=e.number)),n},e.toObject=function(e,n){n||(n={});var t={};return n.defaults&&(n.bytes===String?t.number="":(t.number=[],n.bytes!==Array&&(t.number=$util.newBuffer(t.number)))),null!=e.number&&e.hasOwnProperty("number")&&(t.number=n.bytes===String?$util.base64.encode(e.number,0,e.number.length):n.bytes===Array?Array.prototype.slice.call(e.number):e.number),t},e.prototype.toJSON=function(){return this.constructor.toObject(this,$protobuf.util.toJSONOptions)},e}(),module.exports=$root; - -},{"protobufjs/minimal":64}],15:[function(require,module,exports){ +},{"./account":2,"./account_creator":3,"./connection":4,"./contract":5,"./key_stores":9,"./key_stores/unencrypted_file_system_keystore":12,"./utils/key_pair":20,"bn.js":27}],14:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const provider_1=require("./provider");exports.Provider=provider_1.Provider,exports.getTransactionLastResult=provider_1.getTransactionLastResult;const json_rpc_provider_1=require("./json-rpc-provider");exports.JsonRpcProvider=json_rpc_provider_1.JsonRpcProvider; -},{"./json-rpc-provider":16,"./provider":17}],16:[function(require,module,exports){ +},{"./json-rpc-provider":15,"./provider":16}],15:[function(require,module,exports){ (function (Buffer){ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const provider_1=require("./provider"),web_1=require("../utils/web"),serialize_1=require("../utils/serialize"),protos_1=require("../protos");let _nextId=123;class JsonRpcProvider extends provider_1.Provider{constructor(r,e){super(),this.connection={url:r}}async getNetwork(){return{name:"test",chainId:"test"}}async status(){return this.sendJsonRpc("status",[])}async sendTransaction(r){const e=protos_1.SignedTransaction.encode(r).finish();return this.sendJsonRpc("broadcast_tx_commit",[Buffer.from(e).toString("base64")])}async txStatus(r){return this.sendJsonRpc("tx",[serialize_1.base_encode(r)])}async query(r,e){const s=await this.sendJsonRpc("query",[r,e]);if(s.error)throw new Error(`Quering ${r} failed: ${s.error}.\n${JSON.stringify(s,null,2)}`);return s}async block(r){return this.sendJsonRpc("block",[r])}async sendJsonRpc(r,e){const s={method:r,params:e,id:_nextId++,jsonrpc:"2.0"},t=await web_1.fetchJson(this.connection,JSON.stringify(s));if(t.error)throw new Error(`[${t.error.code}] ${t.error.message}: ${t.error.data}`);return t.result}}exports.JsonRpcProvider=JsonRpcProvider; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const provider_1=require("./provider"),web_1=require("../utils/web"),serialize_1=require("../utils/serialize");let _nextId=123;class JsonRpcProvider extends provider_1.Provider{constructor(r,e){super(),this.connection={url:r}}async getNetwork(){return{name:"test",chainId:"test"}}async status(){return this.sendJsonRpc("status",[])}async sendTransaction(r){const e=r.encode();return this.sendJsonRpc("broadcast_tx_commit",[Buffer.from(e).toString("base64")])}async txStatus(r){return this.sendJsonRpc("tx",[serialize_1.base_encode(r)])}async query(r,e){const s=await this.sendJsonRpc("query",[r,e]);if(s.error)throw new Error(`Quering ${r} failed: ${s.error}.\n${JSON.stringify(s,null,2)}`);return s}async block(r){return this.sendJsonRpc("block",[r])}async sendJsonRpc(r,e){const s={method:r,params:e,id:_nextId++,jsonrpc:"2.0"},t=await web_1.fetchJson(this.connection,JSON.stringify(s));if(t.error)throw new Error(`[${t.error.code}] ${t.error.message}: ${t.error.data}`);return t.result}}exports.JsonRpcProvider=JsonRpcProvider; }).call(this,require("buffer").Buffer) -},{"../protos":14,"../utils/serialize":23,"../utils/web":24,"./provider":17,"buffer":39}],17:[function(require,module,exports){ +},{"../utils/serialize":22,"../utils/web":23,"./provider":16,"buffer":31}],16:[function(require,module,exports){ (function (Buffer){ "use strict";var FinalTransactionStatus;Object.defineProperty(exports,"__esModule",{value:!0}),function(t){t.Unknown="Unknown",t.Started="Started",t.Failed="Failed",t.Completed="Completed"}(FinalTransactionStatus=exports.FinalTransactionStatus||(exports.FinalTransactionStatus={}));class Provider{}function getTransactionLastResult(t){for(let e=t.logs.length-1;e>=0;--e){const n=t.logs[e];if(n.result&&n.result.length>0)return JSON.parse(Buffer.from(n.result).toString())}return null}exports.Provider=Provider,exports.getTransactionLastResult=getTransactionLastResult; }).call(this,require("buffer").Buffer) -},{"buffer":39}],18:[function(require,module,exports){ +},{"buffer":31}],17:[function(require,module,exports){ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const js_sha256_1=__importDefault(require("js-sha256")),key_pair_1=require("./utils/key_pair");class Signer{async signMessage(e,r,t){return this.signHash(new Uint8Array(js_sha256_1.default.sha256.array(e)),r,t)}}exports.Signer=Signer;class InMemorySigner extends Signer{constructor(e){super(),this.keyStore=e}async createKey(e,r){const t=key_pair_1.KeyPair.fromRandom("ed25519");return await this.keyStore.setKey(r,e,t),t.getPublicKey()}async getPublicKey(e,r){return(await this.keyStore.getKey(r,e)).getPublicKey()}async signHash(e,r,t){if(!r)throw new Error("InMemorySigner requires provided account id");const s=await this.keyStore.getKey(t,r);if(null===s)throw new Error(`Key for ${r} not found in ${t}`);return s.sign(e)}}exports.InMemorySigner=InMemorySigner; -},{"./utils/key_pair":21,"js-sha256":58}],19:[function(require,module,exports){ -(function (Buffer){ -"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const js_sha256_1=__importDefault(require("js-sha256")),bn_js_1=__importDefault(require("bn.js")),protos_1=require("./protos"),serialize_1=require("./utils/serialize"),TRANSACTION_FIELD_MAP=new Map([[protos_1.CreateAccountTransaction,"createAccount"],[protos_1.DeployContractTransaction,"deployContract"],[protos_1.FunctionCallTransaction,"functionCall"],[protos_1.SendMoneyTransaction,"sendMoney"],[protos_1.StakeTransaction,"stake"],[protos_1.SwapKeyTransaction,"swapKey"],[protos_1.AddKeyTransaction,"addKey"],[protos_1.DeleteKeyTransaction,"deleteKey"]]);function bigInt(e){const n=new Uint8Array(new bn_js_1.default(e).toArray("le",16));return new protos_1.Uint128({number:n})}function bignumHex2Dec(e){return new bn_js_1.default(e,16).toString(10)}function createAccount(e,n,t,o,r){return new protos_1.CreateAccountTransaction({nonce:e,originator:n,newAccountId:t,publicKey:serialize_1.base_decode(o),amount:bigInt(r)})}function deployContract(e,n,t){return new protos_1.DeployContractTransaction({nonce:e,contractId:n,wasmByteArray:t})}function functionCall(e,n,t,o,r,a){return new protos_1.FunctionCallTransaction({nonce:e,originator:n,contractId:t,methodName:Buffer.from(o),args:r,amount:bigInt(a)})}function sendMoney(e,n,t,o){return new protos_1.SendMoneyTransaction({nonce:e,originator:n,receiver:t,amount:bigInt(o)})}function stake(e,n,t,o){return new protos_1.StakeTransaction({nonce:e,originator:n,amount:bigInt(t),publicKey:o,blsPublicKey:null})}function swapKey(e,n,t,o){return new protos_1.SwapKeyTransaction({nonce:e,originator:n,curKey:serialize_1.base_decode(t),newKey:serialize_1.base_decode(o)})}function createAccessKey(e,n,t,o){return new protos_1.AccessKey({contractId:e?new protos_1.google.protobuf.StringValue({value:e}):null,methodName:n?new protos_1.google.protobuf.BytesValue({value:Buffer.from(n)}):null,balanceOwner:t?new protos_1.google.protobuf.StringValue({value:t}):null,amount:bigInt(o||new bn_js_1.default(0))})}function addKey(e,n,t,o){return new protos_1.AddKeyTransaction({nonce:e,originator:n,newKey:serialize_1.base_decode(t),accessKey:o})}function deleteKey(e,n,t){return new protos_1.DeleteKeyTransaction({nonce:e,originator:n,curKey:serialize_1.base_decode(t)})}function signedTransaction(e,n){const t=TRANSACTION_FIELD_MAP.get(e.constructor);return new protos_1.SignedTransaction({signature:n.signature,publicKey:protos_1.google.protobuf.BytesValue.create({value:serialize_1.base_decode(n.publicKey)}),[t]:e})}async function signTransaction(e,n,t,o){const r=n.constructor.encode(n).finish(),a=new Uint8Array(js_sha256_1.default.sha256.array(r));return[a,signedTransaction(n,await e.signHash(a,t,o))]}exports.bignumHex2Dec=bignumHex2Dec,exports.createAccount=createAccount,exports.deployContract=deployContract,exports.functionCall=functionCall,exports.sendMoney=sendMoney,exports.stake=stake,exports.swapKey=swapKey,exports.createAccessKey=createAccessKey,exports.addKey=addKey,exports.deleteKey=deleteKey,exports.signedTransaction=signedTransaction,exports.signTransaction=signTransaction; +},{"./utils/key_pair":20,"js-sha256":50}],18:[function(require,module,exports){ +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const js_sha256_1=__importDefault(require("js-sha256")),serialize_1=require("./utils/serialize");class Enum{constructor(e){if(1!==Object.keys(e).length)throw new Error("Enum can only take single value");Object.keys(e).map(n=>{this[n]=e[n],this.enum=n})}}class Assignable{constructor(e){Object.keys(e).map(n=>{this[n]=e[n]})}}class FunctionCallPermission extends Assignable{}exports.FunctionCallPermission=FunctionCallPermission;class FullAccessPermission extends Assignable{}exports.FullAccessPermission=FullAccessPermission;class AccessKeyPermission extends Enum{}exports.AccessKeyPermission=AccessKeyPermission;class AccessKey extends Assignable{}function fullAccessKey(){return new AccessKey({nonce:0,permission:new AccessKeyPermission({fullAccess:new FullAccessPermission({})})})}function functionCallAccessKey(e,n,s){return new AccessKey({nonce:0,permission:new AccessKeyPermission({functionCall:new FunctionCallPermission({receiverId:e,allowance:s,methodNames:n})})})}exports.AccessKey=AccessKey,exports.fullAccessKey=fullAccessKey,exports.functionCallAccessKey=functionCallAccessKey;class IAction extends Assignable{}exports.IAction=IAction;class CreateAccount extends IAction{}class DeployContract extends IAction{}class FunctionCall extends IAction{}class Transfer extends IAction{}class Stake extends IAction{}class AddKey extends IAction{}class DeleteKey extends IAction{}class DeleteAccount extends IAction{}function createAccount(){return new Action({createAccount:new CreateAccount({})})}function deployContract(e){return new Action({deployContract:new DeployContract({code:e})})}function functionCall(e,n,s,t){return new Action({functionCall:new FunctionCall({methodName:e,args:n,gas:s,deposit:t})})}function transfer(e){return new Action({transfer:new Transfer({deposit:e})})}function stake(e,n){return new Action({stake:new Stake({stake:e,publicKey:new PublicKey(n)})})}function addKey(e,n){return new Action({addKey:new AddKey({publicKey:new PublicKey(e),accessKey:n})})}function deleteKey(e){return new Action({deleteKey:new DeleteKey({publicKey:new PublicKey(e)})})}function deleteAccount(e){return new Action({deleteAccount:new DeleteAccount({beneficiaryId:e})})}var KeyType;exports.createAccount=createAccount,exports.deployContract=deployContract,exports.functionCall=functionCall,exports.transfer=transfer,exports.stake=stake,exports.addKey=addKey,exports.deleteKey=deleteKey,exports.deleteAccount=deleteAccount,function(e){e[e.ED25519=0]="ED25519"}(KeyType||(KeyType={}));class PublicKey{constructor(e){this.keyType=KeyType.ED25519,this.data=serialize_1.base_decode(e)}}class Signature{constructor(e){this.keyType=KeyType.ED25519,this.data=e}}class Transaction extends Assignable{}class SignedTransaction extends Assignable{encode(){return serialize_1.serialize(SCHEMA,this)}}exports.SignedTransaction=SignedTransaction;class Action extends Enum{}exports.Action=Action;const SCHEMA={Signature:{kind:"struct",fields:[["keyType","u8"],["data",[32]]]},SignedTransaction:{kind:"struct",fields:[["transaction",Transaction],["signature",Signature]]},Transaction:{kind:"struct",fields:[["signerId","string"],["publicKey",PublicKey],["nonce","u64"],["receiverId","string"],["actions",[Action]]]},PublicKey:{kind:"struct",fields:[["keyType","u8"],["data",[32]]]},AccessKey:{kind:"struct",fields:[["nonce","u64"],["permission",AccessKeyPermission]]},AccessKeyPermission:{kind:"enum",field:"enum",values:[["functionCall",FunctionCallPermission],["fullAccess",FullAccessPermission]]},FunctionCallPermission:{kind:"struct",fields:[["allowance",{kind:"option",type:"u128"}],["receiverId","string"],["methodNames",["string"]]]},FullAccessPermission:{kind:"struct",fields:[]},Action:{kind:"enum",field:"enum",values:[["createAccount",CreateAccount],["deployContract",DeployContract],["functionCall",functionCall],["transfer",transfer],["stake",stake],["addKey",addKey],["deleteKey",deleteKey],["deleteAccount",deleteAccount]]},CreateAccount:{kind:"struct",fields:[]},DeployContract:{kind:"struct",fields:[["code",["u8"]]]},FunctionCall:{kind:"struct",fields:[["methodName","string"],["args",["u8"]],["gas","u64"],["deposit","u128"]]},Transfer:{kind:"struct",fields:[["deposit","u128"]]},Stake:{kind:"struct",fields:[["stake","u128"],["publicKey",PublicKey]]},AddKey:{kind:"struct",fields:[["publicKey",PublicKey],["accessKey",AccessKey]]},DeleteKey:{kind:"struct",fields:[["publicKey",PublicKey]]},DeleteAccount:{kind:"struct",fields:[["beneficiaryId","string"]]}};async function signTransaction(e,n,s,t,c,i){const r=new PublicKey(await t.getPublicKey(c,i)),o=new Transaction({signerId:c,publicKey:r,nonce:n,receiverId:e,actions:s}),a=serialize_1.serialize(SCHEMA,o),l=new Uint8Array(js_sha256_1.default.sha256.array(a)),u=await t.signHash(l,c,i);return[l,new SignedTransaction({transaction:o,signature:new Signature(u.signature)})]}exports.signTransaction=signTransaction; -}).call(this,require("buffer").Buffer) -},{"./protos":14,"./utils/serialize":23,"bn.js":35,"buffer":39,"js-sha256":58}],20:[function(require,module,exports){ +},{"./utils/serialize":22,"js-sha256":50}],19:[function(require,module,exports){ "use strict";var __importStar=this&&this.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(null!=r)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e};Object.defineProperty(exports,"__esModule",{value:!0});const key_pair=__importStar(require("./key_pair"));exports.key_pair=key_pair;const network=__importStar(require("./network"));exports.network=network;const serialize=__importStar(require("./serialize"));exports.serialize=serialize;const web=__importStar(require("./web"));exports.web=web;const key_pair_1=require("./key_pair");exports.KeyPair=key_pair_1.KeyPair,exports.KeyPairEd25519=key_pair_1.KeyPairEd25519; -},{"./key_pair":21,"./network":22,"./serialize":23,"./web":24}],21:[function(require,module,exports){ +},{"./key_pair":20,"./network":21,"./serialize":22,"./web":23}],20:[function(require,module,exports){ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const tweetnacl_1=__importDefault(require("tweetnacl")),serialize_1=require("./serialize");class KeyPair{static fromRandom(e){switch(e){case"ed25519":return KeyPairEd25519.fromRandom();default:throw new Error(`Unknown curve ${e}`)}}static fromString(e){const t=e.split(":");if(2!==t.length)throw new Error("Invalid encoded key format, must be :");switch(t[0]){case"ed25519":return new KeyPairEd25519(t[1]);default:throw new Error(`Unknown curve: ${t[0]}`)}}}exports.KeyPair=KeyPair;class KeyPairEd25519 extends KeyPair{constructor(e){super();const t=tweetnacl_1.default.sign.keyPair.fromSecretKey(serialize_1.base_decode(e));this.publicKey=serialize_1.base_encode(t.publicKey),this.secretKey=e}static fromRandom(){const e=tweetnacl_1.default.sign.keyPair();return new KeyPairEd25519(serialize_1.base_encode(e.secretKey))}sign(e){return{signature:tweetnacl_1.default.sign.detached(e,serialize_1.base_decode(this.secretKey)),publicKey:this.publicKey}}verify(e,t){return tweetnacl_1.default.sign.detached.verify(e,t,serialize_1.base_decode(this.publicKey))}toString(){return`ed25519:${this.secretKey}`}getPublicKey(){return this.publicKey}}exports.KeyPairEd25519=KeyPairEd25519; -},{"./serialize":23,"tweetnacl":80}],22:[function(require,module,exports){ +},{"./serialize":22,"tweetnacl":61}],21:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}); -},{}],23:[function(require,module,exports){ +},{}],22:[function(require,module,exports){ (function (Buffer){ -"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const bs58_1=__importDefault(require("bs58"));function base_encode(e){return"string"==typeof e&&(e=Buffer.from(e,"utf8")),bs58_1.default.encode(Buffer.from(e))}function base_decode(e){return bs58_1.default.decode(e)}exports.base_encode=base_encode,exports.base_decode=base_decode; +"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const bs58_1=__importDefault(require("bs58")),bn_js_1=__importDefault(require("bn.js"));function base_encode(e){return"string"==typeof e&&(e=Buffer.from(e,"utf8")),bs58_1.default.encode(Buffer.from(e))}function base_decode(e){return bs58_1.default.decode(e)}exports.base_encode=base_encode,exports.base_decode=base_decode;const INITIAL_LENGTH=1024;class BinaryWriter{constructor(){this.buf=Buffer.alloc(INITIAL_LENGTH),this.length=0}maybe_resize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(INITIAL_LENGTH)]))}write_u8(e){this.maybe_resize(),this.buf.writeUInt8(e,this.length),this.length+=1}write_u32(e){this.maybe_resize(),this.buf.writeUInt32LE(e,this.length),this.length+=4}write_u64(e){this.maybe_resize(),this.write_buffer(Buffer.from(new bn_js_1.default(e).toArray("le",8)))}write_u128(e){this.maybe_resize(),this.write_buffer(Buffer.from(new bn_js_1.default(e).toArray("le",16)))}write_buffer(e){this.buf=Buffer.concat([this.buf.subarray(0,this.length),e,Buffer.alloc(INITIAL_LENGTH)]),this.length+=e.length}write_string(e){this.maybe_resize();const r=Buffer.from(e,"utf8");this.write_u32(r.length),this.write_buffer(r)}write_fixed_array(e){this.write_buffer(Buffer.from(e))}write_array(e,r){this.maybe_resize(),this.write_u32(e.length);for(const t of e)this.maybe_resize(),r(t)}toArray(){return this.buf.subarray(0,this.length)}}exports.BinaryWriter=BinaryWriter;class BinaryReader{constructor(e){this.buf=e,this.offset=0}read_u8(){const e=this.buf.readUInt8(this.offset);return this.offset+=1,e}read_u32(){const e=this.buf.readUInt32LE(this.offset);return this.offset+=4,e}read_u64(){const e=this.read_buffer(8);return e.reverse(),new bn_js_1.default(`${e.toString("hex")}`,16)}read_u128(){const e=this.read_buffer(16);return new bn_js_1.default(e)}read_buffer(e){const r=this.buf.slice(this.offset,this.offset+e);return this.offset+=e,r}read_string(){const e=this.read_u32();return this.read_buffer(e).toString("utf8")}read_fixed_array(e){return new Uint8Array(this.read_buffer(e))}read_array(e){const r=this.read_u32(),t=Array();for(let i=0;i{serializeField(e,r,t[0],i)});else if(void 0!==t.kind)switch(t.kind){case"option":null===r?i.write_u8(0):(i.write_u8(1),serializeField(e,r,t.type,i));break;default:throw new Error(`FieldType ${t} unrecognized`)}else serializeStruct(e,r,i)}function serializeStruct(e,r,t){const i=r.constructor.name;if(void 0===e[i])throw new Error(`Class ${i} is missing in schema`);if("struct"===e[i].kind)e[i].fields.map(([i,s])=>{serializeField(e,r[i],s,t)});else{if("enum"!==e[i].kind)throw new Error(`Unexpected schema kind: ${e[i].kind} for ${i}`);{const s=r[e[i].field];for(let n=0;ndeserializeField(e,r[0],t)):deserializeStruct(e,r,t)}function deserializeStruct(e,r,t){return new r(...e[r.name].fields.map(([r,i])=>deserializeField(e,i,t)))}function deserialize(e,r,t){return deserializeStruct(e,r,new BinaryReader(t))}exports.BinaryReader=BinaryReader,exports.serialize=serialize,exports.deserialize=deserialize; }).call(this,require("buffer").Buffer) -},{"bs58":38,"buffer":39}],24:[function(require,module,exports){ +},{"bn.js":27,"bs58":30,"buffer":31}],23:[function(require,module,exports){ "use strict";var __importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0});const http_errors_1=__importDefault(require("http-errors")),fetch="undefined"==typeof window||"nodejs"===window.name?require("node-fetch"):window.fetch;async function fetchJson(t,e){let o=null;o="string"==typeof t?t:t.url;const r=await fetch(o,{method:e?"POST":"GET",body:e||void 0,headers:{"Content-type":"application/json; charset=utf-8"}});if(!r.ok)throw http_errors_1.default(r.status,await r.text());return await r.json()}exports.fetchJson=fetchJson; -},{"http-errors":55,"node-fetch":37}],25:[function(require,module,exports){ +},{"http-errors":47,"node-fetch":29}],24:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const utils_1=require("./utils"),LOGIN_WALLET_URL_SUFFIX="/login/",LOCAL_STORAGE_KEY_SUFFIX="_wallet_auth_key",PENDING_ACCESS_KEY_PREFIX="pending_key";class WalletAccount{constructor(t,e){this._networkId=t.config.networkId,this._walletBaseUrl=t.config.walletUrl,e=e||t.config.contractName||"default",this._authDataKey=e+LOCAL_STORAGE_KEY_SUFFIX,this._keyStore=t.connection.signer.keyStore,this._authData=JSON.parse(window.localStorage.getItem(this._authDataKey)||"{}"),this.isSignedIn()||this._completeSignInWithAccessKey()}isSignedIn(){return!!this._authData.accountId}getAccountId(){return this._authData.accountId||""}async requestSignIn(t,e,a,s){if(this.getAccountId()||await this._keyStore.getKey(this._networkId,this.getAccountId()))return Promise.resolve();const i=new URL(window.location.href),o=new URL(this._walletBaseUrl+LOGIN_WALLET_URL_SUFFIX);o.searchParams.set("title",e),o.searchParams.set("contract_id",t),o.searchParams.set("success_url",a||i.href),o.searchParams.set("failure_url",s||i.href),o.searchParams.set("app_url",i.origin);const r=utils_1.KeyPair.fromRandom("ed25519");o.searchParams.set("public_key",r.getPublicKey()),await this._keyStore.setKey(this._networkId,PENDING_ACCESS_KEY_PREFIX+r.getPublicKey(),r),window.location.assign(o.toString())}async _completeSignInWithAccessKey(){const t=new URL(window.location.href),e=t.searchParams.get("public_key")||"",a=t.searchParams.get("account_id")||"";a&&e&&(this._authData={accountId:a},window.localStorage.setItem(this._authDataKey,JSON.stringify(this._authData)),await this._moveKeyFromTempToPermanent(a,e))}async _moveKeyFromTempToPermanent(t,e){const a=await this._keyStore.getKey(this._networkId,PENDING_ACCESS_KEY_PREFIX+e);await this._keyStore.setKey(this._networkId,t,a),await this._keyStore.removeKey(this._networkId,PENDING_ACCESS_KEY_PREFIX+e)}signOut(){this._authData={},window.localStorage.removeItem(this._authDataKey)}}exports.WalletAccount=WalletAccount; -},{"./utils":20}],26:[function(require,module,exports){ -"use strict";function asPromise(e,n){for(var r=new Array(arguments.length-1),t=0,l=2,o=!0;l1&&"="===r.charAt(a);)++e;return Math.ceil(3*r.length)/4-e};for(var b64=new Array(64),s64=new Array(123),i=0;i<64;)s64[b64[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;base64.encode=function(r,a,e){for(var i,n=null,t=[],o=0,s=0;a>2],i=(3&c)<<4,s=1;break;case 1:t[o++]=b64[i|c>>4],i=(15&c)<<2,s=2;break;case 2:t[o++]=b64[i|c>>6],t[o++]=b64[63&c],s=0}o>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,t)),o=0)}return s&&(t[o++]=b64[i],t[o++]=61,1===s&&(t[o++]=61)),n?(o&&n.push(String.fromCharCode.apply(String,t.slice(0,o))),n.join("")):String.fromCharCode.apply(String,t.slice(0,o))};var invalidEncoding="invalid encoding";base64.decode=function(r,a,e){for(var i,n=e,t=0,o=0;o1)break;if(void 0===(s=s64[s]))throw Error(invalidEncoding);switch(t){case 0:i=s,t=1;break;case 1:a[e++]=i<<2|(48&s)>>4,i=s,t=2;break;case 2:a[e++]=(15&i)<<4|(60&s)>>2,i=s,t=3;break;case 3:a[e++]=(3&i)<<6|s,t=0}}if(1===t)throw Error(invalidEncoding);return e-n},base64.test=function(r){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r)}; - -},{}],28:[function(require,module,exports){ -"use strict";function EventEmitter(){this._listeners={}}module.exports=EventEmitter,EventEmitter.prototype.on=function(t,e,i){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:e,ctx:i||this}),this},EventEmitter.prototype.off=function(t,e){if(void 0===t)this._listeners={};else if(void 0===e)this._listeners[t]=[];else for(var i=this._listeners[t],s=0;s0?0:2147483648,e,r);else if(isNaN(t))n(2143289344,e,r);else if(t>3.4028234663852886e38)n((i<<31|2139095040)>>>0,e,r);else if(t<1.1754943508222875e-38)n((i<<31|Math.round(t/1.401298464324817e-45))>>>0,e,r);else{var a=Math.floor(Math.log(t)/Math.LN2);n((i<<31|a+127<<23|8388607&Math.round(t*Math.pow(2,-a)*8388608))>>>0,e,r)}}function e(n,t,e){var r=n(t,e),i=2*(r>>31)+1,a=r>>>23&255,o=8388607&r;return 255===a?o?NaN:i*(1/0):0===a?1.401298464324817e-45*i*o:i*Math.pow(2,a-150)*(o+8388608)}n.writeFloatLE=t.bind(null,writeUintLE),n.writeFloatBE=t.bind(null,writeUintBE),n.readFloatLE=e.bind(null,readUintLE),n.readFloatBE=e.bind(null,readUintBE)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),e=new Uint8Array(t.buffer),r=128===e[7];function i(n,r,i){t[0]=n,r[i]=e[0],r[i+1]=e[1],r[i+2]=e[2],r[i+3]=e[3],r[i+4]=e[4],r[i+5]=e[5],r[i+6]=e[6],r[i+7]=e[7]}function a(n,r,i){t[0]=n,r[i]=e[7],r[i+1]=e[6],r[i+2]=e[5],r[i+3]=e[4],r[i+4]=e[3],r[i+5]=e[2],r[i+6]=e[1],r[i+7]=e[0]}function o(n,r){return e[0]=n[r],e[1]=n[r+1],e[2]=n[r+2],e[3]=n[r+3],e[4]=n[r+4],e[5]=n[r+5],e[6]=n[r+6],e[7]=n[r+7],t[0]}function u(n,r){return e[7]=n[r],e[6]=n[r+1],e[5]=n[r+2],e[4]=n[r+3],e[3]=n[r+4],e[2]=n[r+5],e[1]=n[r+6],e[0]=n[r+7],t[0]}n.writeDoubleLE=r?i:a,n.writeDoubleBE=r?a:i,n.readDoubleLE=r?o:u,n.readDoubleBE=r?u:o}():function(){function t(n,t,e,r,i,a){var o=r<0?1:0;if(o&&(r=-r),0===r)n(0,i,a+t),n(1/r>0?0:2147483648,i,a+e);else if(isNaN(r))n(0,i,a+t),n(2146959360,i,a+e);else if(r>1.7976931348623157e308)n(0,i,a+t),n((o<<31|2146435072)>>>0,i,a+e);else{var u;if(r<2.2250738585072014e-308)n((u=r/5e-324)>>>0,i,a+t),n((o<<31|u/4294967296)>>>0,i,a+e);else{var l=Math.floor(Math.log(r)/Math.LN2);1024===l&&(l=1023),n(4503599627370496*(u=r*Math.pow(2,-l))>>>0,i,a+t),n((o<<31|l+1023<<20|1048576*u&1048575)>>>0,i,a+e)}}}function e(n,t,e,r,i){var a=n(r,i+t),o=n(r,i+e),u=2*(o>>31)+1,l=o>>>20&2047,f=4294967296*(1048575&o)+a;return 2047===l?f?NaN:u*(1/0):0===l?5e-324*u*f:u*Math.pow(2,l-1075)*(f+4503599627370496)}n.writeDoubleLE=t.bind(null,writeUintLE,0,4),n.writeDoubleBE=t.bind(null,writeUintBE,4,0),n.readDoubleLE=e.bind(null,readUintLE,0,4),n.readDoubleBE=e.bind(null,readUintBE,4,0)}(),n}function writeUintLE(n,t,e){t[e]=255&n,t[e+1]=n>>>8&255,t[e+2]=n>>>16&255,t[e+3]=n>>>24}function writeUintBE(n,t,e){t[e]=n>>>24,t[e+1]=n>>>16&255,t[e+2]=n>>>8&255,t[e+3]=255&n}function readUintLE(n,t){return(n[t]|n[t+1]<<8|n[t+2]<<16|n[t+3]<<24)>>>0}function readUintBE(n,t){return(n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3])>>>0}module.exports=factory(factory); - -},{}],30:[function(require,module,exports){ -"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire; - -},{}],31:[function(require,module,exports){ -"use strict";function pool(r,n,o){var t=o||8192,u=t>>>1,l=null,e=t;return function(o){if(o<1||o>u)return r(o);e+o>t&&(l=r(t),e=0);var c=n.call(l,e,e+=o);return 7&e&&(e=1+(7|e)),c}}module.exports=pool; - -},{}],32:[function(require,module,exports){ -"use strict";var utf8=exports;utf8.length=function(r){for(var t=0,n=0,e=0;e191&&e<224?a[i++]=(31&e)<<6|63&r[t++]:e>239&&e<365?(e=((7&e)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,a[i++]=55296+(e>>10),a[i++]=56320+(1023&e)):a[i++]=(15&e)<<12|(63&r[t++])<<6|63&r[t++],i>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),i=0);return o?(i&&o.push(String.fromCharCode.apply(String,a.slice(0,i))),o.join("")):String.fromCharCode.apply(String,a.slice(0,i))},utf8.write=function(r,t,n){for(var e,o,a=n,i=0;i>6|192,t[n++]=63&e|128):55296==(64512&e)&&56320==(64512&(o=r.charCodeAt(i+1)))?(e=65536+((1023&e)<<10)+(1023&o),++i,t[n++]=e>>18|240,t[n++]=e>>12&63|128,t[n++]=e>>6&63|128,t[n++]=63&e|128):(t[n++]=e>>12|224,t[n++]=e>>6&63|128,t[n++]=63&e|128);return n-a}; - -},{}],33:[function(require,module,exports){ +},{"./utils":19}],25:[function(require,module,exports){ const Buffer=require("safe-buffer").Buffer;module.exports=function(r){if(r.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);e.fill(255);for(let t=0;t>>0,a=new Uint8Array(i);for(;r[f];){let o=e[r.charCodeAt(f)];if(255===o)return;let n=0;for(let r=i-1;(0!==o||n>>0,a[r]=o%256>>>0,o=o/256>>>0;if(0!==o)throw new Error("Non-zero carry");c=n,f++}if(" "===r[f])return;let h=i-c;for(;h!==i&&0===a[h];)h++;const u=Buffer.allocUnsafe(l+(i-h));u.fill(0,0,l);let s=l;for(;h!==i;)u[s++]=a[h++];return u}return{encode:function(e){if(!Buffer.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";let n=0,l=0,c=0;const i=e.length;for(;c!==i&&0===e[c];)c++,n++;const a=(i-c)*f+1>>>0,h=new Uint8Array(a);for(;c!==i;){let r=e[c],o=0;for(let e=a-1;(0!==r||o>>0,h[e]=r%t>>>0,r=r/t>>>0;if(0!==r)throw new Error("Non-zero carry");l=o,c++}let u=a-l;for(;u!==a&&0===h[u];)u++;let s=o.repeat(n);for(;u0)throw new Error("Invalid string. Length must be a multiple of 4");var e=o.indexOf("=");return-1===e&&(e=r),[e,e===r?0:4-e%4]}function byteLength(o){var r=getLens(o),e=r[0],t=r[1];return 3*(e+t)/4-t}function _byteLength(o,r,e){return 3*(r+e)/4-e}function toByteArray(o){for(var r,e=getLens(o),t=e[0],n=e[1],u=new Arr(_byteLength(o,t,n)),p=0,a=n>0?t-4:t,h=0;h>16&255,u[p++]=r>>8&255,u[p++]=255&r;return 2===n&&(r=revLookup[o.charCodeAt(h)]<<2|revLookup[o.charCodeAt(h+1)]>>4,u[p++]=255&r),1===n&&(r=revLookup[o.charCodeAt(h)]<<10|revLookup[o.charCodeAt(h+1)]<<4|revLookup[o.charCodeAt(h+2)]>>2,u[p++]=r>>8&255,u[p++]=255&r),u}function tripletToBase64(o){return lookup[o>>18&63]+lookup[o>>12&63]+lookup[o>>6&63]+lookup[63&o]}function encodeChunk(o,r,e){for(var t,n=[],u=r;up?p:u+16383));return 1===t?(r=o[e-1],n.push(lookup[r>>2]+lookup[r<<4&63]+"==")):2===t&&(r=(o[e-2]<<8)+o[e-1],n.push(lookup[r>>10]+lookup[r>>4&63]+lookup[r<<2&63]+"=")),n.join("")}revLookup["-".charCodeAt(0)]=62,revLookup["_".charCodeAt(0)]=63; -},{}],35:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ !function(t,i){"use strict";function r(t,i){if(!t)throw new Error(i||"Assertion failed")}function h(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,i,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var e;"object"==typeof t?t.exports=n:i.BN=n,n.BN=n,n.wordSize=26;try{e=require("buffer").Buffer}catch(t){}function o(t,i,r){for(var h=0,n=Math.min(t.length,r),e=i;e=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return h}function s(t,i,r,h){for(var n=0,e=Math.min(t.length,r),o=i;o=49?s-49+10:s>=17?s-17+10:s}return n}n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,i){return t.cmp(i)>0?t:i},n.min=function(t,i){return t.cmp(i)<0?t:i},n.prototype._init=function(t,i,h){if("number"==typeof t)return this._initNumber(t,i,h);if("object"==typeof t)return this._initArray(t,i,h);"hex"===i&&(i=16),r(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===i?this._parseHex(t,n):this._parseBase(t,i,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initNumber=function(t,i,h){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===h&&this._initArray(this.toArray(),i,h)},n.prototype._initArray=function(t,i,h){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===h)for(n=0,e=0;n>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this.strip()},n.prototype._parseHex=function(t,i){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var r=0;r=i;r-=6)n=o(t,r,r+6),this.words[h]|=n<>>26-e&4194303,(e+=24)>=26&&(e-=26,h++);r+6!==i&&(n=o(t,i,r+6),this.words[h]|=n<>>26-e&4194303),this.strip()},n.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,u=Math.min(e,e-o)+r,a=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],a=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var a=1;a>>26,m=67108863&u,f=Math.min(a,i.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[a]=0|m,u=0|l}return 0!==u?r.words[a]=0|u:r.length--,r.strip()}n.prototype.toString=function(t,i){var h;if(i=0|i||1,16===(t=t||10)||"hex"===t){h="";for(var n=0,e=0,o=0;o>>24-n&16777215)||o!==this.length-1?u[6-m.length]+m+h:m+h,(n+=2)>=26&&(n-=26,o--)}for(0!==e&&(h=e.toString(16)+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}if(t===(0|t)&&t>=2&&t<=36){var f=a[t],d=l[t];h="";var p=this.clone();for(p.negative=0;!p.isZero();){var M=p.modn(d).toString(t);h=(p=p.idivn(d)).isZero()?M+h:u[f-M.length]+M+h}for(this.isZero()&&(h="0"+h);h.length%i!=0;)h="0"+h;return 0!==this.negative&&(h="-"+h),h}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(t,i){return r(void 0!==e),this.toArrayLike(e,t,i)},n.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},n.prototype.toArrayLike=function(t,i,h){var n=this.byteLength(),e=h||Math.max(1,n);r(n<=e,"byte array longer than desired length"),r(e>0,"Requested array length <= 0"),this.strip();var o,s,u="le"===i,a=new t(e),l=this.clone();if(u){for(s=0;!l.isZero();s++)o=l.andln(255),l.iushrn(8),a[s]=o;for(;s=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},n.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;it.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;ht.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),h=t%26;this._expand(i),h>0&&i--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-h),this.strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,i){r("number"==typeof t&&t>=0);var h=t/26|0,n=t%26;return this._expand(h+1),this.words[h]=i?this.words[h]|1<t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e>>26;for(;0!==n&&e>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;et.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o>26,this.words[o]=67108863&i;for(;0!==e&&o>26,this.words[o]=67108863&i;if(0===e&&o>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,x=0|o[5],S=8191&x,Z=x>>>13,q=0|o[6],R=8191&q,B=q>>>13,N=0|o[7],L=8191&N,I=N>>>13,z=0|o[8],T=8191&z,E=z>>>13,O=0|o[9],j=8191&O,K=O>>>13,P=0|s[0],F=8191&P,C=P>>>13,D=0|s[1],H=8191&D,J=D>>>13,U=0|s[2],G=8191&U,Q=U>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191<,ft=lt>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(a+(h=Math.imul(m,F))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,F)|0))<<13)|0;a=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,F),n=(n=Math.imul(p,C))+Math.imul(M,F)|0,e=Math.imul(M,C);var gt=(a+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,H)|0))<<13)|0;a=((e=e+Math.imul(f,J)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,F),n=(n=Math.imul(g,C))+Math.imul(c,F)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,J)|0;var ct=(a+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;a=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,F),n=(n=Math.imul(y,C))+Math.imul(b,F)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,J)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,J)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(a+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;a=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,F),n=(n=Math.imul(k,C))+Math.imul(A,F)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,J)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(a+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;a=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(S,F),n=(n=Math.imul(S,C))+Math.imul(Z,F)|0,e=Math.imul(Z,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,J)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,J)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(a+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;a=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(R,F),n=(n=Math.imul(R,C))+Math.imul(B,F)|0,e=Math.imul(B,C),h=h+Math.imul(S,H)|0,n=(n=n+Math.imul(S,J)|0)+Math.imul(Z,H)|0,e=e+Math.imul(Z,J)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(a+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;a=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(L,F),n=(n=Math.imul(L,C))+Math.imul(I,F)|0,e=Math.imul(I,C),h=h+Math.imul(R,H)|0,n=(n=n+Math.imul(R,J)|0)+Math.imul(B,H)|0,e=e+Math.imul(B,J)|0,h=h+Math.imul(S,G)|0,n=(n=n+Math.imul(S,Q)|0)+Math.imul(Z,G)|0,e=e+Math.imul(Z,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(a+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((e=e+Math.imul(f,at)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(T,F),n=(n=Math.imul(T,C))+Math.imul(E,F)|0,e=Math.imul(E,C),h=h+Math.imul(L,H)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(I,H)|0,e=e+Math.imul(I,J)|0,h=h+Math.imul(R,G)|0,n=(n=n+Math.imul(R,Q)|0)+Math.imul(B,G)|0,e=e+Math.imul(B,Q)|0,h=h+Math.imul(S,W)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(Z,W)|0,e=e+Math.imul(Z,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,at)|0;var At=(a+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,F),n=(n=Math.imul(j,C))+Math.imul(K,F)|0,e=Math.imul(K,C),h=h+Math.imul(T,H)|0,n=(n=n+Math.imul(T,J)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,J)|0,h=h+Math.imul(L,G)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(I,G)|0,e=e+Math.imul(I,Q)|0,h=h+Math.imul(R,W)|0,n=(n=n+Math.imul(R,X)|0)+Math.imul(B,W)|0,e=e+Math.imul(B,X)|0,h=h+Math.imul(S,$)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(Z,$)|0,e=e+Math.imul(Z,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,at)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var xt=(a+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,J))+Math.imul(K,H)|0,e=Math.imul(K,J),h=h+Math.imul(T,G)|0,n=(n=n+Math.imul(T,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(L,W)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(I,W)|0,e=e+Math.imul(I,X)|0,h=h+Math.imul(R,$)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(B,$)|0,e=e+Math.imul(B,tt)|0,h=h+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,ht)|0)+Math.imul(Z,rt)|0,e=e+Math.imul(Z,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,at)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var St=(a+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;a=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(T,W)|0,n=(n=n+Math.imul(T,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(I,$)|0,e=e+Math.imul(I,tt)|0,h=h+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,ht)|0)+Math.imul(B,rt)|0,e=e+Math.imul(B,ht)|0,h=h+Math.imul(S,et)|0,n=(n=n+Math.imul(S,ot)|0)+Math.imul(Z,et)|0,e=e+Math.imul(Z,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,at)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,at)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var Zt=(a+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;a=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(T,$)|0,n=(n=n+Math.imul(T,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(I,rt)|0,e=e+Math.imul(I,ht)|0,h=h+Math.imul(R,et)|0,n=(n=n+Math.imul(R,ot)|0)+Math.imul(B,et)|0,e=e+Math.imul(B,ot)|0,h=h+Math.imul(S,ut)|0,n=(n=n+Math.imul(S,at)|0)+Math.imul(Z,ut)|0,e=e+Math.imul(Z,at)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var qt=(a+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;a=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(T,rt)|0,n=(n=n+Math.imul(T,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(L,et)|0,n=(n=n+Math.imul(L,ot)|0)+Math.imul(I,et)|0,e=e+Math.imul(I,ot)|0,h=h+Math.imul(R,ut)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(B,ut)|0,e=e+Math.imul(B,at)|0,h=h+Math.imul(S,mt)|0,n=(n=n+Math.imul(S,ft)|0)+Math.imul(Z,mt)|0,e=e+Math.imul(Z,ft)|0;var Rt=(a+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;a=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(T,et)|0,n=(n=n+Math.imul(T,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(I,ut)|0,e=e+Math.imul(I,at)|0,h=h+Math.imul(R,mt)|0,n=(n=n+Math.imul(R,ft)|0)+Math.imul(B,mt)|0,e=e+Math.imul(B,ft)|0;var Bt=(a+(h=h+Math.imul(S,pt)|0)|0)+((8191&(n=(n=n+Math.imul(S,Mt)|0)+Math.imul(Z,pt)|0))<<13)|0;a=((e=e+Math.imul(Z,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(T,ut)|0,n=(n=n+Math.imul(T,at)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,at)|0,h=h+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(I,mt)|0,e=e+Math.imul(I,ft)|0;var Nt=(a+(h=h+Math.imul(R,pt)|0)|0)+((8191&(n=(n=n+Math.imul(R,Mt)|0)+Math.imul(B,pt)|0))<<13)|0;a=((e=e+Math.imul(B,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,at))+Math.imul(K,ut)|0,e=Math.imul(K,at),h=h+Math.imul(T,mt)|0,n=(n=n+Math.imul(T,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(a+(h=h+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,Mt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((e=e+Math.imul(I,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var It=(a+(h=h+Math.imul(T,pt)|0)|0)+((8191&(n=(n=n+Math.imul(T,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863;var zt=(a+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return a=((e=Math.imul(K,Mt))+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=xt,u[10]=St,u[11]=Zt,u[12]=qt,u[13]=Rt,u[14]=Bt,u[15]=Nt,u[16]=Lt,u[17]=It,u[18]=zt,0!==a&&(u[19]=a,r.length++),r};function d(t,i,r){return(new p).mulp(t,i,r)}function p(t,i){this.x=t,this.y=i}Math.imul||(f=m),n.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?f(this,t,i):r<63?m(this,t,i):r<1024?function(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r.strip()}(this,t,i):d(this,t,i)},p.prototype.makeRBT=function(t){for(var i=new Array(t),r=n.prototype._countBits(t)-1,h=0;h>=1;return h},p.prototype.permute=function(t,i,r,h,n,e){for(var o=0;o>>=1)n++;return 1<>>=13,h[2*o+1]=8191&e,e>>>=13;for(o=2*i;o>=26,i+=n/67108864|0,i+=e>>>26,this.words[h]=67108863&e}return 0!==i&&(this.words[h]=i,this.length++),this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r>>n}return i}(t);if(0===i.length)return new n(1);for(var r=this,h=0;h=0);var i,h=t%26,n=(t-h)/26,e=67108863>>>26-h<<26-h;if(0!==h){var o=0;for(i=0;i>>26-h}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<o)for(this.length-=o,a=0;a=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-e|m>>>e,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(t,i,h){return r(0===this.negative),this.iushrn(t,i,h)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var i=t%26,h=(t-i)/26,n=1<=0);var i=t%26,h=(t-i)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=h)return this;if(0!==i&&h++,this.length=Math.min(h,this.length),0!==i){var n=67108863^67108863>>>i<=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i>26)-(u/67108864|0),this.words[n+h]=67108863&e}for(;n>26,this.words[n+h]=67108863&e;if(0===s)return this.strip();for(r(-1===s),s=0,n=0;n>26,this.words[n]=67108863&e;return this.negative=1,this.strip()},n.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),e=t,o=0|e.words[e.length-1];0!==(r=26-this._countBits(o))&&(e=e.ushln(r),h.iushln(r),o=0|e.words[e.length-1]);var s,u=h.length-e.length;if("mod"!==i){(s=new n(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a=0;m--){var f=67108864*(0|h.words[e.length+m])+(0|h.words[e.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(e,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(e,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s.strip(),h.strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},n.prototype.divmod=function(t,i,h){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(e=s.div.neg()),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.iadd(t)),{div:e,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(e=s.div.neg()),{div:e,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),h&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new n(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modn(t.words[0]))}:this._wordDiv(t,i);var e,o,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},n.prototype.modn=function(t){r(t<=67108863);for(var i=(1<<26)%t,h=0,n=this.length-1;n>=0;n--)h=(i*h+(0|this.words[n]))%t;return h},n.prototype.idivn=function(t){r(t<=67108863);for(var i=0,h=this.length-1;h>=0;h--){var n=(0|this.words[h])+67108864*i;this.words[h]=n/t|0,i=n%t}return this.strip()},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e=new n(1),o=new n(0),s=new n(0),u=new n(1),a=0;i.isEven()&&h.isEven();)i.iushrn(1),h.iushrn(1),++a;for(var l=h.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(e.isOdd()||o.isOdd())&&(e.iadd(l),o.isub(m)),e.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(h.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(h.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(h)>=0?(i.isub(h),e.isub(s),o.isub(u)):(h.isub(i),s.isub(e),u.isub(o))}return{a:s,b:u,gcd:h.iushln(a)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var i=this,h=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var e,o=new n(1),s=new n(0),u=h.clone();i.cmpn(1)>0&&h.cmpn(1)>0;){for(var a=0,l=1;0==(i.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(i.iushrn(a);a-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(h.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(h.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(h)>=0?(i.isub(h),o.isub(s)):(h.isub(i),s.isub(o))}return(e=0===i.cmpn(1)?o:s).cmpn(0)<0&&e.iadd(t),e},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var i=t%26,h=(t-i)/26,n=1<>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var i,h=t<0;if(0!==this.negative&&!h)return-1;if(0===this.negative&&h)return 1;if(this.strip(),this.length>1)i=1;else{h&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:nt.length)return 1;if(this.length=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){hn&&(i=1);break}}return i},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new b(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var M={k256:null,p224:null,p192:null,p25519:null};function v(t,i){this.name=t,this.p=new n(i,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function c(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var i=n._prime(t);this.m=i.p,this.prime=i}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,i){t.iushrn(this.n,0,i)},v.prototype.imulK=function(t){return t.imul(this.k)},h(g,v),g.prototype.split=function(t,i){for(var r=Math.min(t.length,9),h=0;h>>22,n=e}n>>>=22,t.words[h-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},g.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},n._prime=function(t){if(M[t])return M[t];var i;if("k256"===t)i=new g;else if("p224"===t)i=new c;else if("p192"===t)i=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new y}return M[t]=i,i},b.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,i){r(0==(t.negative|i.negative),"red works only with positives"),r(t.red&&t.red===i.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},b.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},b.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},b.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(r(i%2==1),3===i){var h=this.m.add(new n(1)).iushrn(2);return this.pow(t,h)}for(var e=this.m.subn(1),o=0;!e.isZero()&&0===e.andln(1);)o++,e.iushrn(1);r(!e.isZero());var s=new n(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,e),f=this.pow(t,e.addn(1).iushrn(1)),d=this.pow(t,e),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();r(v=0;h--){for(var a=i.words[h],l=u-1;l>=0;l--){var m=a>>l&1;e!==r[0]&&(e=this.sqr(e)),0!==m||0!==o?(o<<=1,o|=m,(4===++s||0===h&&0===l)&&(e=this.mul(e,r[o]),s=0,o=0)):s=0}u=26}return e},b.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},b.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},n.mont=function(t){return new _(t)},h(_,b),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},_.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},_.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new n(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),e=r.isub(h).iushrn(this.shift),o=e;return e.cmp(this.m)>=0?o=e.isub(this.m):e.cmpn(0)<0&&(o=e.iadd(this.m)),o._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}("undefined"==typeof module||module,this); -},{"buffer":36}],36:[function(require,module,exports){ +},{"buffer":28}],28:[function(require,module,exports){ -},{}],37:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ -},{}],38:[function(require,module,exports){ +},{}],30:[function(require,module,exports){ var basex=require("base-x"),ALPHABET="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";module.exports=basex(ALPHABET); -},{"base-x":33}],39:[function(require,module,exports){ +},{"base-x":25}],31:[function(require,module,exports){ (function (Buffer){ "use strict";var base64=require("base64-js"),ieee754=require("ieee754");exports.Buffer=Buffer,exports.SlowBuffer=SlowBuffer,exports.INSPECT_MAX_BYTES=50;var K_MAX_LENGTH=2147483647;function typedArraySupport(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}function createBuffer(e){if(e>K_MAX_LENGTH)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=Buffer.prototype,t}function Buffer(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"==typeof e)return fromString(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return Buffer.from(n,t,r);var f=fromObject(e);if(f)return f;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function alloc(e,t,r){return assertSize(e),e<=0?createBuffer(e):void 0!==t?"string"==typeof r?createBuffer(e).fill(t,r):createBuffer(e).fill(t):createBuffer(e)}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromString(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);return f!==r&&(n=n.slice(0,f)),n}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=K_MAX_LENGTH)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+K_MAX_LENGTH.toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer.alloc(+e)}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var f=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(f)return n?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),f=!0}}function slowToString(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){var i,o=1,u=e.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,s/=2,r/=2}function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(f){var h=-1;for(i=r;iu&&(r=u-s),i=r;i>=0;i--){for(var c=!0,l=0;lf&&(n=f):n=f;var i=t.length;n>i/2&&(n=i/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(f+c<=r)switch(c){case 1:a<128&&(h=a);break;case 2:128==(192&(i=e[f+1]))&&(s=(31&a)<<6|63&i)>127&&(h=s);break;case 3:i=e[f+1],o=e[f+2],128==(192&i)&&128==(192&o)&&(s=(15&a)<<12|(63&i)<<6|63&o)>2047&&(s<55296||s>57343)&&(h=s);break;case 4:i=e[f+1],o=e[f+2],u=e[f+3],128==(192&i)&&128==(192&o)&&128==(192&u)&&(s=(15&a)<<18|(63&i)<<12|(63&o)<<6|63&u)>65535&&s<1114112&&(h=s)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),f+=c}return decodeCodePointsArray(n)}exports.kMaxLength=K_MAX_LENGTH,Buffer.TYPED_ARRAY_SUPPORT=typedArraySupport(),Buffer.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(Buffer.prototype,"parent",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.buffer}}),Object.defineProperty(Buffer.prototype,"offset",{enumerable:!0,get:function(){if(Buffer.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&Buffer[Symbol.species]===Buffer&&Object.defineProperty(Buffer,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),Buffer.poolSize=8192,Buffer.from=function(e,t,r){return from(e,t,r)},Buffer.prototype.__proto__=Uint8Array.prototype,Buffer.__proto__=Uint8Array,Buffer.alloc=function(e,t,r){return alloc(e,t,r)},Buffer.allocUnsafe=function(e){return allocUnsafe(e)},Buffer.allocUnsafeSlow=function(e){return allocUnsafe(e)},Buffer.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==Buffer.prototype},Buffer.compare=function(e,t){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),isInstance(t,Uint8Array)&&(t=Buffer.from(t,t.offset,t.byteLength)),!Buffer.isBuffer(e)||!Buffer.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,f=0,i=Math.min(r,n);ft&&(e+=" ... "),""},Buffer.prototype.compare=function(e,t,r,n,f){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(f>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),s=this.slice(n,f),a=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),ieee754.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,f){return t=+t,r>>>=0,f||checkIEEE754(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),ieee754.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=(f*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return i>=(f*=128)&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return e>>>=0,t||checkOffset(e,4,this.length),ieee754.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return e>>>=0,t||checkOffset(e,8,this.length),ieee754.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return f},Buffer.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var f=e.charCodeAt(0);("utf8"===n&&f<128||"latin1"===n)&&(e=f)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function asciiToBytes(e){for(var t=[],r=0;r>8,f=r%256,i.push(f),i.push(n);return i}function base64ToBytes(e){return base64.toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!=e} }).call(this,require("buffer").Buffer) -},{"base64-js":34,"buffer":39,"ieee754":56}],40:[function(require,module,exports){ +},{"base64-js":26,"buffer":31,"ieee754":48}],32:[function(require,module,exports){ require(".").check("es5"); -},{".":41}],41:[function(require,module,exports){ +},{".":33}],33:[function(require,module,exports){ require("./lib/definitions"),module.exports=require("./lib"); -},{"./lib":44,"./lib/definitions":43}],42:[function(require,module,exports){ +},{"./lib":36,"./lib/definitions":35}],34:[function(require,module,exports){ var CapabilityDetector=function(){this.tests={},this.cache={}};CapabilityDetector.prototype={constructor:CapabilityDetector,define:function(t,i){if("string"!=typeof t||!(i instanceof Function))throw new Error("Invalid capability definition.");if(this.tests[t])throw new Error('Duplicated capability definition by "'+t+'".');this.tests[t]=i},check:function(t){if(!this.test(t))throw new Error('The current environment does not support "'+t+'", therefore we cannot continue.')},test:function(t){if(void 0!==this.cache[t])return this.cache[t];if(!this.tests[t])throw new Error('Unknown capability with name "'+t+'".');var i=this.tests[t];return this.cache[t]=!!i(),this.cache[t]}},module.exports=CapabilityDetector; -},{}],43:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ var capability=require("."),define=capability.define,test=capability.test;define("strict mode",function(){return void 0===this}),define("arguments.callee.caller",function(){try{return function(){return arguments.callee.caller}()===arguments.callee}catch(e){return!1}}),define("es5",function(){return test("Array.prototype.forEach")&&test("Array.prototype.map")&&test("Function.prototype.bind")&&test("Object.create")&&test("Object.defineProperties")&&test("Object.defineProperty")&&test("Object.prototype.hasOwnProperty")}),define("Array.prototype.forEach",function(){return Array.prototype.forEach}),define("Array.prototype.map",function(){return Array.prototype.map}),define("Function.prototype.bind",function(){return Function.prototype.bind}),define("Object.create",function(){return Object.create}),define("Object.defineProperties",function(){return Object.defineProperties}),define("Object.defineProperty",function(){return Object.defineProperty}),define("Object.prototype.hasOwnProperty",function(){return Object.prototype.hasOwnProperty}),define("Error.captureStackTrace",function(){return Error.captureStackTrace}),define("Error.prototype.stack",function(){try{throw new Error}catch(e){return e.stack||e.stacktrace}}); -},{".":44}],44:[function(require,module,exports){ +},{".":36}],36:[function(require,module,exports){ var CapabilityDetector=require("./CapabilityDetector"),detector=new CapabilityDetector,capability=function(t){return detector.test(t)};capability.define=function(t,e){detector.define(t,e)},capability.check=function(t){detector.check(t)},capability.test=capability,module.exports=capability; -},{"./CapabilityDetector":42}],45:[function(require,module,exports){ +},{"./CapabilityDetector":34}],37:[function(require,module,exports){ "use strict";function depd(r){if(!r)throw new TypeError("argument namespace is required");function e(r){}return e._file=void 0,e._ignored=!0,e._namespace=r,e._traced=!1,e._warned=Object.create(null),e.function=wrapfunction,e.property=wrapproperty,e}function wrapfunction(r,e){if("function"!=typeof r)throw new TypeError("argument fn must be a function");return r}function wrapproperty(r,e,t){if(!r||"object"!=typeof r&&"function"!=typeof r)throw new TypeError("argument obj must be object");var o=Object.getOwnPropertyDescriptor(r,e);if(!o)throw new TypeError("must call property on owner object");if(!o.configurable)throw new TypeError("property must be configurable")}module.exports=depd; -},{}],46:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ module.exports=require("./lib"); -},{"./lib":47}],47:[function(require,module,exports){ +},{"./lib":39}],39:[function(require,module,exports){ require("capability/es5");var polyfill,capability=require("capability");polyfill=capability("Error.captureStackTrace")?require("./v8"):capability("Error.prototype.stack")?require("./non-v8/index"):require("./unsupported"),module.exports=polyfill(); -},{"./non-v8/index":51,"./unsupported":53,"./v8":54,"capability":41,"capability/es5":40}],48:[function(require,module,exports){ +},{"./non-v8/index":43,"./unsupported":45,"./v8":46,"capability":33,"capability/es5":32}],40:[function(require,module,exports){ var Class=require("o3").Class,abstractMethod=require("o3").abstractMethod,Frame=Class(Object,{prototype:{init:Class.prototype.merge,frameString:void 0,toString:function(){return this.frameString},functionValue:void 0,getThis:abstractMethod,getTypeName:abstractMethod,getFunction:function(){return this.functionValue},getFunctionName:abstractMethod,getMethodName:abstractMethod,getFileName:abstractMethod,getLineNumber:abstractMethod,getColumnNumber:abstractMethod,getEvalOrigin:abstractMethod,isTopLevel:abstractMethod,isEval:abstractMethod,isNative:abstractMethod,isConstructor:abstractMethod}});module.exports=Frame; -},{"o3":59}],49:[function(require,module,exports){ +},{"o3":51}],41:[function(require,module,exports){ var Class=require("o3").Class,Frame=require("./Frame"),cache=require("u3").cache,FrameStringParser=Class(Object,{prototype:{stackParser:null,frameParser:null,locationParsers:null,constructor:function(e){Class.prototype.merge.call(this,e)},getFrames:function(e,r){for(var t=[],a=0,n=e.length;a=600)&&deprecate("non-error status code; use only 4xx or 5xx status codes"),("number"!=typeof t||!statuses[t]&&(t<400||t>=600))&&(t=500);var n=createError[t]||createError[codeClass(t)];for(var u in r||(r=n?new n(e):new Error(e||statuses[t]),Error.captureStackTrace(r,createError)),n&&r instanceof n&&r.status===t||(r.expose=t<500,r.status=r.statusCode=t),o)"status"!==u&&"statusCode"!==u&&(r[u]=o[u]);return r}function createHttpErrorConstructor(){function r(){throw new TypeError("cannot construct abstract class")}return inherits(r,Error),r}function createClientErrorConstructor(r,e,t){var o=e.match(/Error$/)?e:e+"Error";function a(r){var e=null!=r?r:statuses[t],s=new Error(e);return Error.captureStackTrace(s,a),setPrototypeOf(s,a.prototype),Object.defineProperty(s,"message",{enumerable:!0,configurable:!0,value:e,writable:!0}),Object.defineProperty(s,"name",{enumerable:!1,configurable:!0,value:o,writable:!0}),s}return inherits(a,r),nameFunc(a,o),a.prototype.status=t,a.prototype.statusCode=t,a.prototype.expose=!0,a}function createServerErrorConstructor(r,e,t){var o=e.match(/Error$/)?e:e+"Error";function a(r){var e=null!=r?r:statuses[t],s=new Error(e);return Error.captureStackTrace(s,a),setPrototypeOf(s,a.prototype),Object.defineProperty(s,"message",{enumerable:!0,configurable:!0,value:e,writable:!0}),Object.defineProperty(s,"name",{enumerable:!1,configurable:!0,value:o,writable:!0}),s}return inherits(a,r),nameFunc(a,o),a.prototype.status=t,a.prototype.statusCode=t,a.prototype.expose=!1,a}function nameFunc(r,e){var t=Object.getOwnPropertyDescriptor(r,"name");t&&t.configurable&&(t.value=e,Object.defineProperty(r,"name",t))}function populateConstructorExports(r,e,t){e.forEach(function(e){var o,a=toIdentifier(statuses[e]);switch(codeClass(e)){case 400:o=createClientErrorConstructor(t,a,e);break;case 500:o=createServerErrorConstructor(t,a,e)}o&&(r[e]=o,r[a]=o)}),r["I'mateapot"]=deprecate.function(r.ImATeapot,'"I\'mateapot"; use "ImATeapot" instead')}module.exports=createError,module.exports.HttpError=createHttpErrorConstructor(),populateConstructorExports(module.exports,statuses.codes,module.exports.HttpError); -},{"depd":45,"inherits":57,"setprototypeof":76,"statuses":78,"toidentifier":79}],56:[function(require,module,exports){ +},{"depd":37,"inherits":49,"setprototypeof":57,"statuses":59,"toidentifier":60}],48:[function(require,module,exports){ exports.read=function(a,o,t,r,h){var M,p,w=8*h-r-1,f=(1<>1,i=-7,N=t?h-1:0,n=t?-1:1,s=a[o+N];for(N+=n,M=s&(1<<-i)-1,s>>=-i,i+=w;i>0;M=256*M+a[o+N],N+=n,i-=8);for(p=M&(1<<-i)-1,M>>=-i,i+=r;i>0;p=256*p+a[o+N],N+=n,i-=8);if(0===M)M=1-e;else{if(M===f)return p?NaN:1/0*(s?-1:1);p+=Math.pow(2,r),M-=e}return(s?-1:1)*p*Math.pow(2,M-r)},exports.write=function(a,o,t,r,h,M){var p,w,f,e=8*M-h-1,i=(1<>1,n=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,s=r?0:M-1,u=r?1:-1,l=o<0||0===o&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(w=isNaN(o)?1:0,p=i):(p=Math.floor(Math.log(o)/Math.LN2),o*(f=Math.pow(2,-p))<1&&(p--,f*=2),(o+=p+N>=1?n/f:n*Math.pow(2,1-N))*f>=2&&(p++,f/=2),p+N>=i?(w=0,p=i):p+N>=1?(w=(o*f-1)*Math.pow(2,h),p+=N):(w=o*Math.pow(2,N-1)*Math.pow(2,h),p=0));h>=8;a[t+s]=255&w,s+=u,w/=256,h-=8);for(p=p<0;a[t+s]=255&p,s+=u,p/=256,e-=8);a[t+s-u]|=128*l}; -},{}],57:[function(require,module,exports){ -"function"==typeof Object.create?module.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:module.exports=function(t,e){if(e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}}; +},{}],49:[function(require,module,exports){ +"function"==typeof Object.create?module.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(t,e){t.super_=e;var o=function(){};o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t}; -},{}],58:[function(require,module,exports){ +},{}],50:[function(require,module,exports){ (function (process,global){ !function(){"use strict";var ERROR="input is invalid type",WINDOW="object"==typeof window,root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&"object"==typeof self,NODE_JS=!root.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;NODE_JS?root=global:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&"object"==typeof module&&module.exports,AMD="function"==typeof define&&define.amd,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];!root.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!ARRAY_BUFFER||!root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var createOutputMethod=function(t,h){return function(r){return new Sha256(h,!0).update(r)[t]()}},createMethod=function(t){var h=createOutputMethod("hex",t);NODE_JS&&(h=nodeWrap(h,t)),h.create=function(){return new Sha256(t)},h.update=function(t){return h.create().update(t)};for(var r=0;r>6,o[H++]=128|63&i):i<55296||i>=57344?(o[H++]=224|i>>12,o[H++]=128|i>>6&63,o[H++]=128|63&i):(i=65536+((1023&i)<<10|1023&t.charCodeAt(++e)),o[H++]=240|i>>18,o[H++]=128|i>>12&63,o[H++]=128|i>>6&63,o[H++]=128|63&i);t=o}else{if("object"!==s)throw new Error(ERROR);if(null===t)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ARRAY_BUFFER&&ArrayBuffer.isView(t)))throw new Error(ERROR)}t.length>64&&(t=new Sha256(h,!0).update(t).array());var n=[],S=[];for(e=0;e<64;++e){var c=t[e]||0;n[e]=92^c,S[e]=54^c}Sha256.call(this,h,r),this.update(S),this.oKeyPad=n,this.inner=!0,this.sharedMemory=r}Sha256.prototype.update=function(t){if(!this.finalized){var h,r=typeof t;if("string"!==r){if("object"!==r)throw new Error(ERROR);if(null===t)throw new Error(ERROR);if(ARRAY_BUFFER&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||ARRAY_BUFFER&&ArrayBuffer.isView(t)))throw new Error(ERROR);h=!0}for(var e,s,i=0,o=t.length,a=this.blocks;i>2]|=t[i]<>2]|=e<>2]|=(192|e>>6)<>2]|=(128|63&e)<=57344?(a[s>>2]|=(224|e>>12)<>2]|=(128|e>>6&63)<>2]|=(128|63&e)<>2]|=(240|e>>18)<>2]|=(128|e>>12&63)<>2]|=(128|e>>6&63)<>2]|=(128|63&e)<=64?(this.block=a[16],this.start=s-64,this.hash(),this.hashed=!0):this.start=s}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,h=this.lastByteIndex;t[16]=this.block,t[h>>2]|=EXTRA[3&h],this.block=t[16],h>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var t,h,r,e,s,i,o,a,H,n=this.h0,S=this.h1,c=this.h2,f=this.h3,A=this.h4,R=this.h5,u=this.h6,_=this.h7,E=this.blocks;for(t=16;t<64;++t)h=((s=E[t-15])>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,r=((s=E[t-2])>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,E[t]=E[t-16]+h+E[t-7]+r<<0;for(H=S&c,t=0;t<64;t+=4)this.first?(this.is224?(i=300032,_=(s=E[0]-1413257819)-150054599<<0,f=s+24177077<<0):(i=704751109,_=(s=E[0]-210244248)-1521486534<<0,f=s+143694565<<0),this.first=!1):(h=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),e=(i=n&S)^n&c^H,_=f+(s=_+(r=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&R^~A&u)+K[t]+E[t])<<0,f=s+(h+e)<<0),h=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),e=(o=f&n)^f&S^i,u=c+(s=u+(r=(_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&R)+K[t+1]+E[t+1])<<0,h=((c=s+(h+e)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),e=(a=c&f)^c&n^o,R=S+(s=R+(r=(u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&_^~u&A)+K[t+2]+E[t+2])<<0,h=((S=s+(h+e)<<0)>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10),e=(H=S&c)^S&f^a,A=n+(s=A+(r=(R>>>6|R<<26)^(R>>>11|R<<21)^(R>>>25|R<<7))+(R&u^~R&_)+K[t+3]+E[t+3])<<0,n=s+(h+e)<<0;this.h0=this.h0+n<<0,this.h1=this.h1+S<<0,this.h2=this.h2+c<<0,this.h3=this.h3+f<<0,this.h4=this.h4+A<<0,this.h5=this.h5+R<<0,this.h6=this.h6+u<<0,this.h7=this.h7+_<<0},Sha256.prototype.hex=function(){this.finalize();var t=this.h0,h=this.h1,r=this.h2,e=this.h3,s=this.h4,i=this.h5,o=this.h6,a=this.h7,H=HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[h>>28&15]+HEX_CHARS[h>>24&15]+HEX_CHARS[h>>20&15]+HEX_CHARS[h>>16&15]+HEX_CHARS[h>>12&15]+HEX_CHARS[h>>8&15]+HEX_CHARS[h>>4&15]+HEX_CHARS[15&h]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[15&r]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[15&i]+HEX_CHARS[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[15&o];return this.is224||(H+=HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[15&a]),H},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var t=this.h0,h=this.h1,r=this.h2,e=this.h3,s=this.h4,i=this.h5,o=this.h6,a=this.h7,H=[t>>24&255,t>>16&255,t>>8&255,255&t,h>>24&255,h>>16&255,h>>8&255,255&h,r>>24&255,r>>16&255,r>>8&255,255&r,e>>24&255,e>>16&255,e>>8&255,255&e,s>>24&255,s>>16&255,s>>8&255,255&s,i>>24&255,i>>16&255,i>>8&255,255&i,o>>24&255,o>>16&255,o>>8&255,255&o];return this.is224||H.push(a>>24&255,a>>16&255,a>>8&255,255&a),H},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),h=new DataView(t);return h.setUint32(0,this.h0),h.setUint32(4,this.h1),h.setUint32(8,this.h2),h.setUint32(12,this.h3),h.setUint32(16,this.h4),h.setUint32(20,this.h5),h.setUint32(24,this.h6),this.is224||h.setUint32(28,this.h7),t},HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var t=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(t),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224,AMD&&define(function(){return exports}))}(); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":63}],59:[function(require,module,exports){ +},{"_process":55}],51:[function(require,module,exports){ require("capability/es5"),module.exports=require("./lib"); -},{"./lib":62,"capability/es5":40}],60:[function(require,module,exports){ +},{"./lib":54,"capability/es5":32}],52:[function(require,module,exports){ var Class=function(){var t=Object.create({Source:Object,config:{},buildArgs:[]});function o(o){var r="config";if(o instanceof Function)r="Source";else if(o instanceof Array)r="buildArgs";else{if(!(o instanceof Object))throw new Error("Invalid configuration option.");r="config"}if(t.hasOwnProperty(r))throw new Error("Duplicated configuration option: "+r+".");t[r]=o}for(var r=0,e=arguments.length;r1)for(var r=1;r "+t.len)}function Reader(t){this.buf=t,this.pos=0,this.len=t.length}var create_array="undefined"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new Reader(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new Reader(t);throw Error("illegal buffer")};function readLongVarint(){var t=new LongBits(0,0),i=0;if(!(this.len-this.pos>4)){for(;i<3;++i){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(127&this.buf[this.pos++])<<7*i)>>>0,t}for(;i<4;++i)if(t.lo=(t.lo|(127&this.buf[this.pos])<<7*i)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(127&this.buf[this.pos])<<28)>>>0,t.hi=(t.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return t;if(i=0,this.len-this.pos>4){for(;i<5;++i)if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}else for(;i<5;++i){if(this.pos>=this.len)throw indexOutOfRange(this);if(t.hi=(t.hi|(127&this.buf[this.pos])<<7*i+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}function readFixed32_end(t,i){return(t[i-4]|t[i-3]<<8|t[i-2]<<16|t[i-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.create=util.Buffer?function(t){return(Reader.create=function(t){return util.Buffer.isBuffer(t)?new BufferReader(t):create_array(t)})(t)}:create_array,Reader.prototype._slice=util.Array.prototype.subarray||util.Array.prototype.slice,Reader.prototype.uint32=function(){var t=4294967295;return function(){if(t=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return t;if(t=(t|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return t;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return t}}(),Reader.prototype.int32=function(){return 0|this.uint32()},Reader.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},Reader.prototype.bool=function(){return 0!==this.uint32()},Reader.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var t=util.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},Reader.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var t=util.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},Reader.prototype.bytes=function(){var t=this.uint32(),i=this.pos,e=this.pos+t;if(e>this.len)throw indexOutOfRange(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(i,e):i===e?new this.buf.constructor(0):this._slice.call(this.buf,i,e)},Reader.prototype.string=function(){var t=this.bytes();return utf8.read(t,0,t.length)},Reader.prototype.skip=function(t){if("number"==typeof t){if(this.pos+t>this.len)throw indexOutOfRange(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw indexOutOfRange(this)}while(128&this.buf[this.pos++]);return this},Reader.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this},Reader._configure=function(t){BufferReader=t;var i=util.Long?"toLong":"toNumber";util.merge(Reader.prototype,{int64:function(){return readLongVarint.call(this)[i](!1)},uint64:function(){return readLongVarint.call(this)[i](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[i](!1)},fixed64:function(){return readFixed64.call(this)[i](!0)},sfixed64:function(){return readFixed64.call(this)[i](!1)}})}; - -},{"./util/minimal":72}],67:[function(require,module,exports){ -"use strict";module.exports=BufferReader;var Reader=require("./reader");(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util=require("./util/minimal");function BufferReader(e){Reader.call(this,e)}util.Buffer&&(BufferReader.prototype._slice=util.Buffer.prototype.slice),BufferReader.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len))}; - -},{"./reader":66,"./util/minimal":72}],68:[function(require,module,exports){ -"use strict";module.exports={}; - -},{}],69:[function(require,module,exports){ -"use strict";var rpc=exports;rpc.Service=require("./rpc/service"); - -},{"./rpc/service":70}],70:[function(require,module,exports){ -"use strict";module.exports=Service;var util=require("../util/minimal");function Service(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");util.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(Service.prototype=Object.create(util.EventEmitter.prototype)).constructor=Service,Service.prototype.rpcCall=function e(t,r,i,n,o){if(!n)throw TypeError("request must be specified");var l=this;if(!o)return util.asPromise(e,l,t,r,i,n);if(l.rpcImpl)try{return l.rpcImpl(t,r[l.requestDelimited?"encodeDelimited":"encode"](n).finish(),function(e,r){if(e)return l.emit("error",e,t),o(e);if(null!==r){if(!(r instanceof i))try{r=i[l.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return l.emit("error",e,t),o(e)}return l.emit("data",r,t),o(null,r)}l.end(!0)})}catch(e){return l.emit("error",e,t),void setTimeout(function(){o(e)},0)}else setTimeout(function(){o(Error("already ended"))},0)},Service.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}; - -},{"../util/minimal":72}],71:[function(require,module,exports){ -"use strict";module.exports=LongBits;var util=require("../util/minimal");function LongBits(t,o){this.lo=t>>>0,this.hi=o>>>0}var zero=LongBits.zero=new LongBits(0,0);zero.toNumber=function(){return 0},zero.zzEncode=zero.zzDecode=function(){return this},zero.length=function(){return 1};var zeroHash=LongBits.zeroHash="\0\0\0\0\0\0\0\0";LongBits.fromNumber=function(t){if(0===t)return zero;var o=t<0;o&&(t=-t);var i=t>>>0,r=(t-i)/4294967296>>>0;return o&&(r=~r>>>0,i=~i>>>0,++i>4294967295&&(i=0,++r>4294967295&&(r=0))),new LongBits(i,r)},LongBits.from=function(t){if("number"==typeof t)return LongBits.fromNumber(t);if(util.isString(t)){if(!util.Long)return LongBits.fromNumber(parseInt(t,10));t=util.Long.fromString(t)}return t.low||t.high?new LongBits(t.low>>>0,t.high>>>0):zero},LongBits.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var o=1+~this.lo>>>0,i=~this.hi>>>0;return o||(i=i+1>>>0),-(o+4294967296*i)}return this.lo+4294967296*this.hi},LongBits.prototype.toLong=function(t){return util.Long?new util.Long(0|this.lo,0|this.hi,Boolean(t)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(t)}};var charCodeAt=String.prototype.charCodeAt;LongBits.fromHash=function(t){return t===zeroHash?zero:new LongBits((charCodeAt.call(t,0)|charCodeAt.call(t,1)<<8|charCodeAt.call(t,2)<<16|charCodeAt.call(t,3)<<24)>>>0,(charCodeAt.call(t,4)|charCodeAt.call(t,5)<<8|charCodeAt.call(t,6)<<16|charCodeAt.call(t,7)<<24)>>>0)},LongBits.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},LongBits.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this},LongBits.prototype.zzDecode=function(){var t=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this},LongBits.prototype.length=function(){var t=this.lo,o=(this.lo>>>28|this.hi<<4)>>>0,i=this.hi>>>24;return 0===i?0===o?t<16384?t<128?1:2:t<2097152?3:4:o<16384?o<128?5:6:o<2097152?7:8:i<128?9:10}; - -},{"../util/minimal":72}],72:[function(require,module,exports){ -(function (global){ -"use strict";var util=exports;function merge(t,e,r){for(var i=Object.keys(e),o=0;o0)},util.Buffer=function(){try{var t=util.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(t){return null}}(),util._Buffer_from=null,util._Buffer_allocUnsafe=null,util.newBuffer=function(t){return"number"==typeof t?util.Buffer?util._Buffer_allocUnsafe(t):new util.Array(t):util.Buffer?util._Buffer_from(t):"undefined"==typeof Uint8Array?t:new Uint8Array(t)},util.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,util.Long=util.global.dcodeIO&&util.global.dcodeIO.Long||util.global.Long||util.inquire("long"),util.key2Re=/^true|false|0|1$/,util.key32Re=/^-?(?:0|[1-9][0-9]*)$/,util.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,util.longToHash=function(t){return t?util.LongBits.from(t).toHash():util.LongBits.zeroHash},util.longFromHash=function(t,e){var r=util.LongBits.fromHash(t);return util.Long?util.Long.fromBits(r.lo,r.hi,e):r.toNumber(Boolean(e))},util.merge=merge,util.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)},util.newError=newError,util.ProtocolError=newError("ProtocolError"),util.oneOfGetter=function(t){for(var e={},r=0;r-1;--r)if(1===e[t[r]]&&void 0!==this[t[r]]&&null!==this[t[r]])return t[r]}},util.oneOfSetter=function(t){return function(e){for(var r=0;r127;)i[r++]=127&t|128,t>>>=7;i[r]=t}function VarintOp(t,i){this.len=t,this.next=void 0,this.val=i}function writeVarint64(t,i,r){for(;t.hi;)i[r++]=127&t.lo|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)i[r++]=127&t.lo|128,t.lo=t.lo>>>7;i[r++]=t.lo}function writeFixed32(t,i,r){i[r]=255&t,i[r+1]=t>>>8&255,i[r+2]=t>>>16&255,i[r+3]=t>>>24}Writer.create=util.Buffer?function(){return(Writer.create=function(){return new BufferWriter})()}:function(){return new Writer},Writer.alloc=function(t){return new util.Array(t)},util.Array!==Array&&(Writer.alloc=util.pool(Writer.alloc,util.Array.prototype.subarray)),Writer.prototype._push=function(t,i,r){return this.tail=this.tail.next=new Op(t,i,r),this.len+=i,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new VarintOp((t>>>=0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this},Writer.prototype.int32=function(t){return t<0?this._push(writeVarint64,10,LongBits.fromNumber(t)):this.uint32(t)},Writer.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)},Writer.prototype.uint64=function(t){var i=LongBits.from(t);return this._push(writeVarint64,i.length(),i)},Writer.prototype.int64=Writer.prototype.uint64,Writer.prototype.sint64=function(t){var i=LongBits.from(t).zzEncode();return this._push(writeVarint64,i.length(),i)},Writer.prototype.bool=function(t){return this._push(writeByte,1,t?1:0)},Writer.prototype.fixed32=function(t){return this._push(writeFixed32,4,t>>>0)},Writer.prototype.sfixed32=Writer.prototype.fixed32,Writer.prototype.fixed64=function(t){var i=LongBits.from(t);return this._push(writeFixed32,4,i.lo)._push(writeFixed32,4,i.hi)},Writer.prototype.sfixed64=Writer.prototype.fixed64,Writer.prototype.float=function(t){return this._push(util.float.writeFloatLE,4,t)},Writer.prototype.double=function(t){return this._push(util.float.writeDoubleLE,8,t)};var writeBytes=util.Array.prototype.set?function(t,i,r){i.set(t,r)}:function(t,i,r){for(var e=0;e>>0;if(!i)return this._push(writeByte,1,0);if(util.isString(t)){var r=Writer.alloc(i=base64.length(t));base64.decode(t,r,0),t=r}return this.uint32(i)._push(writeBytes,i,t)},Writer.prototype.string=function(t){var i=utf8.length(t);return i?this.uint32(i)._push(utf8.write,i,t):this._push(writeByte,1,0)},Writer.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer.prototype.ldelim=function(){var t=this.head,i=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=t.next,this.tail=i,this.len+=r),this},Writer.prototype.finish=function(){for(var t=this.head.next,i=this.constructor.alloc(this.len),r=0;t;)t.fn(t.val,i,r),r+=t.len,t=t.next;return i},Writer._configure=function(t){BufferWriter=t}; - -},{"./util/minimal":72}],74:[function(require,module,exports){ -"use strict";module.exports=BufferWriter;var Writer=require("./writer");(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util=require("./util/minimal"),Buffer=util.Buffer;function BufferWriter(){Writer.call(this)}BufferWriter.alloc=function(r){return(BufferWriter.alloc=util._Buffer_allocUnsafe)(r)};var writeBytesBuffer=Buffer&&Buffer.prototype instanceof Uint8Array&&"set"===Buffer.prototype.set.name?function(r,t,e){t.set(r,e)}:function(r,t,e){if(r.copy)r.copy(t,e,0,r.length);else for(var f=0;f>>0;return this.uint32(t),t&&this._push(writeBytesBuffer,t,r),this},BufferWriter.prototype.string=function(r){var t=Buffer.byteLength(r);return this.uint32(t),t&&this._push(writeStringBuffer,t,r),this}; - -},{"./util/minimal":72,"./writer":73}],75:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ var buffer=require("buffer"),Buffer=buffer.Buffer;function copyProps(f,r){for(var e in f)r[e]=f[e]}function SafeBuffer(f,r,e){return Buffer(f,r,e)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?module.exports=buffer:(copyProps(buffer,exports),exports.Buffer=SafeBuffer),copyProps(Buffer,SafeBuffer),SafeBuffer.from=function(f,r,e){if("number"==typeof f)throw new TypeError("Argument must not be a number");return Buffer(f,r,e)},SafeBuffer.alloc=function(f,r,e){if("number"!=typeof f)throw new TypeError("Argument must be a number");var u=Buffer(f);return void 0!==r?"string"==typeof e?u.fill(r,e):u.fill(r):u.fill(0),u},SafeBuffer.allocUnsafe=function(f){if("number"!=typeof f)throw new TypeError("Argument must be a number");return Buffer(f)},SafeBuffer.allocUnsafeSlow=function(f){if("number"!=typeof f)throw new TypeError("Argument must be a number");return buffer.SlowBuffer(f)}; -},{"buffer":39}],76:[function(require,module,exports){ +},{"buffer":31}],57:[function(require,module,exports){ "use strict";function setProtoOf(r,t){return r.__proto__=t,r}function mixinProperties(r,t){for(var o in t)r.hasOwnProperty(o)||(r[o]=t[o]);return r}module.exports=Object.setPrototypeOf||({__proto__:[]}instanceof Array?setProtoOf:mixinProperties); -},{}],77:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ module.exports={ "100": "Continue", "101": "Switching Protocols", @@ -310,33 +249,33 @@ module.exports={ "511": "Network Authentication Required" } -},{}],78:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ "use strict";var codes=require("./codes.json");function populateStatusesMap(t,s){var r=[];return Object.keys(s).forEach(function(e){var a=s[e],u=Number(e);t[u]=a,t[a]=u,t[a.toLowerCase()]=u,r.push(u)}),r}function status(t){if("number"==typeof t){if(!status[t])throw new Error("invalid status code: "+t);return t}if("string"!=typeof t)throw new TypeError("code must be a number or string");var s=parseInt(t,10);if(!isNaN(s)){if(!status[s])throw new Error("invalid status code: "+s);return s}if(!(s=status[t.toLowerCase()]))throw new Error('invalid status message: "'+t+'"');return s}module.exports=status,status.STATUS_CODES=codes,status.codes=populateStatusesMap(status,codes),status.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},status.empty={204:!0,205:!0,304:!0},status.retry={502:!0,503:!0,504:!0}; -},{"./codes.json":77}],79:[function(require,module,exports){ +},{"./codes.json":58}],60:[function(require,module,exports){ function toIdentifier(e){return e.split(" ").map(function(e){return e.slice(0,1).toUpperCase()+e.slice(1)}).join("").replace(/[^ _0-9a-z]/gi,"")}module.exports=toIdentifier; -},{}],80:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ !function(r){"use strict";var t=function(r){var t,n=new Float64Array(16);if(r)for(t=0;t>24&255,r[t+1]=n>>16&255,r[t+2]=n>>8&255,r[t+3]=255&n,r[t+4]=e>>24&255,r[t+5]=e>>16&255,r[t+6]=e>>8&255,r[t+7]=255&e}function v(r,t,n,e,o){var i,h=0;for(i=0;i>>8)-1}function w(r,t,n,e){return v(r,t,n,e,16)}function p(r,t,n,e){return v(r,t,n,e,32)}function b(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,v=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,w=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,_=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,A=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=i,d=h,E=a,x=f,M=s,m=u,B=c,S=y,K=l,Y=v,k=w,T=p,L=b,z=g,R=_,P=A,N=0;N<20;N+=2)U^=(o=(L^=(o=(K^=(o=(M^=(o=U+L|0)<<7|o>>>25)+U|0)<<9|o>>>23)+M|0)<<13|o>>>19)+K|0)<<18|o>>>14,m^=(o=(d^=(o=(z^=(o=(Y^=(o=m+d|0)<<7|o>>>25)+m|0)<<9|o>>>23)+Y|0)<<13|o>>>19)+z|0)<<18|o>>>14,k^=(o=(B^=(o=(E^=(o=(R^=(o=k+B|0)<<7|o>>>25)+k|0)<<9|o>>>23)+R|0)<<13|o>>>19)+E|0)<<18|o>>>14,P^=(o=(T^=(o=(S^=(o=(x^=(o=P+T|0)<<7|o>>>25)+P|0)<<9|o>>>23)+x|0)<<13|o>>>19)+S|0)<<18|o>>>14,U^=(o=(x^=(o=(E^=(o=(d^=(o=U+x|0)<<7|o>>>25)+U|0)<<9|o>>>23)+d|0)<<13|o>>>19)+E|0)<<18|o>>>14,m^=(o=(M^=(o=(S^=(o=(B^=(o=m+M|0)<<7|o>>>25)+m|0)<<9|o>>>23)+B|0)<<13|o>>>19)+S|0)<<18|o>>>14,k^=(o=(Y^=(o=(K^=(o=(T^=(o=k+Y|0)<<7|o>>>25)+k|0)<<9|o>>>23)+T|0)<<13|o>>>19)+K|0)<<18|o>>>14,P^=(o=(R^=(o=(z^=(o=(L^=(o=P+R|0)<<7|o>>>25)+P|0)<<9|o>>>23)+L|0)<<13|o>>>19)+z|0)<<18|o>>>14;U=U+i|0,d=d+h|0,E=E+a|0,x=x+f|0,M=M+s|0,m=m+u|0,B=B+c|0,S=S+y|0,K=K+l|0,Y=Y+v|0,k=k+w|0,T=T+p|0,L=L+b|0,z=z+g|0,R=R+_|0,P=P+A|0,r[0]=U>>>0&255,r[1]=U>>>8&255,r[2]=U>>>16&255,r[3]=U>>>24&255,r[4]=d>>>0&255,r[5]=d>>>8&255,r[6]=d>>>16&255,r[7]=d>>>24&255,r[8]=E>>>0&255,r[9]=E>>>8&255,r[10]=E>>>16&255,r[11]=E>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=M>>>0&255,r[17]=M>>>8&255,r[18]=M>>>16&255,r[19]=M>>>24&255,r[20]=m>>>0&255,r[21]=m>>>8&255,r[22]=m>>>16&255,r[23]=m>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=S>>>0&255,r[29]=S>>>8&255,r[30]=S>>>16&255,r[31]=S>>>24&255,r[32]=K>>>0&255,r[33]=K>>>8&255,r[34]=K>>>16&255,r[35]=K>>>24&255,r[36]=Y>>>0&255,r[37]=Y>>>8&255,r[38]=Y>>>16&255,r[39]=Y>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=T>>>0&255,r[45]=T>>>8&255,r[46]=T>>>16&255,r[47]=T>>>24&255,r[48]=L>>>0&255,r[49]=L>>>8&255,r[50]=L>>>16&255,r[51]=L>>>24&255,r[52]=z>>>0&255,r[53]=z>>>8&255,r[54]=z>>>16&255,r[55]=z>>>24&255,r[56]=R>>>0&255,r[57]=R>>>8&255,r[58]=R>>>16&255,r[59]=R>>>24&255,r[60]=P>>>0&255,r[61]=P>>>8&255,r[62]=P>>>16&255,r[63]=P>>>24&255}(r,t,n,e)}function g(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,v=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,w=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,_=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,A=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=0;U<20;U+=2)i^=(o=(b^=(o=(l^=(o=(s^=(o=i+b|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+l|0)<<18|o>>>14,u^=(o=(h^=(o=(g^=(o=(v^=(o=u+h|0)<<7|o>>>25)+u|0)<<9|o>>>23)+v|0)<<13|o>>>19)+g|0)<<18|o>>>14,w^=(o=(c^=(o=(a^=(o=(_^=(o=w+c|0)<<7|o>>>25)+w|0)<<9|o>>>23)+_|0)<<13|o>>>19)+a|0)<<18|o>>>14,A^=(o=(p^=(o=(y^=(o=(f^=(o=A+p|0)<<7|o>>>25)+A|0)<<9|o>>>23)+f|0)<<13|o>>>19)+y|0)<<18|o>>>14,i^=(o=(f^=(o=(a^=(o=(h^=(o=i+f|0)<<7|o>>>25)+i|0)<<9|o>>>23)+h|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(s^=(o=(y^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+y|0)<<18|o>>>14,w^=(o=(v^=(o=(l^=(o=(p^=(o=w+v|0)<<7|o>>>25)+w|0)<<9|o>>>23)+p|0)<<13|o>>>19)+l|0)<<18|o>>>14,A^=(o=(_^=(o=(g^=(o=(b^=(o=A+_|0)<<7|o>>>25)+A|0)<<9|o>>>23)+b|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=w>>>0&255,r[9]=w>>>8&255,r[10]=w>>>16&255,r[11]=w>>>24&255,r[12]=A>>>0&255,r[13]=A>>>8&255,r[14]=A>>>16&255,r[15]=A>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=y>>>0&255,r[21]=y>>>8&255,r[22]=y>>>16&255,r[23]=y>>>24&255,r[24]=l>>>0&255,r[25]=l>>>8&255,r[26]=l>>>16&255,r[27]=l>>>24&255,r[28]=v>>>0&255,r[29]=v>>>8&255,r[30]=v>>>16&255,r[31]=v>>>24&255}(r,t,n,e)}var _=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function A(r,t,n,e,o,i,h){var a,f,s=new Uint8Array(16),u=new Uint8Array(64);for(f=0;f<16;f++)s[f]=0;for(f=0;f<8;f++)s[f]=i[f];for(;o>=64;){for(b(u,s,h,_),f=0;f<64;f++)r[t+f]=n[e+f]^u[f];for(a=1,f=8;f<16;f++)a=a+(255&s[f])|0,s[f]=255&a,a>>>=8;o-=64,t+=64,e+=64}if(o>0)for(b(u,s,h,_),f=0;f=64;){for(b(f,a,o,_),h=0;h<64;h++)r[t+h]=f[h];for(i=1,h=8;h<16;h++)i=i+(255&a[h])|0,a[h]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(b(f,a,o,_),h=0;h>>13|n<<3),e=255&r[4]|(255&r[5])<<8,this.r[2]=7939&(n>>>10|e<<6),o=255&r[6]|(255&r[7])<<8,this.r[3]=8191&(e>>>7|o<<9),i=255&r[8]|(255&r[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,h=255&r[10]|(255&r[11])<<8,this.r[6]=8191&(i>>>14|h<<2),a=255&r[12]|(255&r[13])<<8,this.r[7]=8065&(h>>>11|a<<5),f=255&r[14]|(255&r[15])<<8,this.r[8]=8191&(a>>>8|f<<8),this.r[9]=f>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function M(r,t,n,e,o,i){var h=new x(i);return h.update(n,e,o),h.finish(r,t),0}function m(r,t,n,e,o,i){var h=new Uint8Array(16);return M(h,0,n,e,o,i),w(r,t,h,0)}function B(r,t,n,e,o){var i;if(n<32)return-1;for(E(r,0,t,0,n,e,o),M(r,16,r,32,n-32,r),i=0;i<16;i++)r[i]=0;return 0}function S(r,t,n,e,o){var i,h=new Uint8Array(32);if(n<32)return-1;if(d(h,0,32,e,o),0!==m(t,16,t,32,n-32,h))return-1;for(E(r,0,t,0,n,e,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,t){var n;for(n=0;n<16;n++)r[n]=0|t[n]}function Y(r){var t,n,e=1;for(t=0;t<16;t++)n=r[t]+e+65535,e=Math.floor(n/65536),r[t]=n-65536*e;r[0]+=e-1+37*(e-1)}function k(r,t,n){for(var e,o=~(n-1),i=0;i<16;i++)e=o&(r[i]^t[i]),r[i]^=e,t[i]^=e}function T(r,n){var e,o,i,h=t(),a=t();for(e=0;e<16;e++)a[e]=n[e];for(Y(a),Y(a),Y(a),o=0;o<2;o++){for(h[0]=a[0]-65517,e=1;e<15;e++)h[e]=a[e]-65535-(h[e-1]>>16&1),h[e-1]&=65535;h[15]=a[15]-32767-(h[14]>>16&1),i=h[15]>>16&1,h[14]&=65535,k(a,h,1-i)}for(e=0;e<16;e++)r[2*e]=255&a[e],r[2*e+1]=a[e]>>8}function L(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return T(n,r),T(e,t),p(n,0,e,0)}function z(r){var t=new Uint8Array(32);return T(t,r),1&t[0]}function R(r,t){var n;for(n=0;n<16;n++)r[n]=t[2*n]+(t[2*n+1]<<8);r[15]&=32767}function P(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]+n[e]}function N(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]-n[e]}function O(r,t,n){var e,o,i=0,h=0,a=0,f=0,s=0,u=0,c=0,y=0,l=0,v=0,w=0,p=0,b=0,g=0,_=0,A=0,U=0,d=0,E=0,x=0,M=0,m=0,B=0,S=0,K=0,Y=0,k=0,T=0,L=0,z=0,R=0,P=n[0],N=n[1],O=n[2],C=n[3],F=n[4],I=n[5],G=n[6],Z=n[7],q=n[8],V=n[9],X=n[10],D=n[11],j=n[12],H=n[13],J=n[14],Q=n[15];i+=(e=t[0])*P,h+=e*N,a+=e*O,f+=e*C,s+=e*F,u+=e*I,c+=e*G,y+=e*Z,l+=e*q,v+=e*V,w+=e*X,p+=e*D,b+=e*j,g+=e*H,_+=e*J,A+=e*Q,h+=(e=t[1])*P,a+=e*N,f+=e*O,s+=e*C,u+=e*F,c+=e*I,y+=e*G,l+=e*Z,v+=e*q,w+=e*V,p+=e*X,b+=e*D,g+=e*j,_+=e*H,A+=e*J,U+=e*Q,a+=(e=t[2])*P,f+=e*N,s+=e*O,u+=e*C,c+=e*F,y+=e*I,l+=e*G,v+=e*Z,w+=e*q,p+=e*V,b+=e*X,g+=e*D,_+=e*j,A+=e*H,U+=e*J,d+=e*Q,f+=(e=t[3])*P,s+=e*N,u+=e*O,c+=e*C,y+=e*F,l+=e*I,v+=e*G,w+=e*Z,p+=e*q,b+=e*V,g+=e*X,_+=e*D,A+=e*j,U+=e*H,d+=e*J,E+=e*Q,s+=(e=t[4])*P,u+=e*N,c+=e*O,y+=e*C,l+=e*F,v+=e*I,w+=e*G,p+=e*Z,b+=e*q,g+=e*V,_+=e*X,A+=e*D,U+=e*j,d+=e*H,E+=e*J,x+=e*Q,u+=(e=t[5])*P,c+=e*N,y+=e*O,l+=e*C,v+=e*F,w+=e*I,p+=e*G,b+=e*Z,g+=e*q,_+=e*V,A+=e*X,U+=e*D,d+=e*j,E+=e*H,x+=e*J,M+=e*Q,c+=(e=t[6])*P,y+=e*N,l+=e*O,v+=e*C,w+=e*F,p+=e*I,b+=e*G,g+=e*Z,_+=e*q,A+=e*V,U+=e*X,d+=e*D,E+=e*j,x+=e*H,M+=e*J,m+=e*Q,y+=(e=t[7])*P,l+=e*N,v+=e*O,w+=e*C,p+=e*F,b+=e*I,g+=e*G,_+=e*Z,A+=e*q,U+=e*V,d+=e*X,E+=e*D,x+=e*j,M+=e*H,m+=e*J,B+=e*Q,l+=(e=t[8])*P,v+=e*N,w+=e*O,p+=e*C,b+=e*F,g+=e*I,_+=e*G,A+=e*Z,U+=e*q,d+=e*V,E+=e*X,x+=e*D,M+=e*j,m+=e*H,B+=e*J,S+=e*Q,v+=(e=t[9])*P,w+=e*N,p+=e*O,b+=e*C,g+=e*F,_+=e*I,A+=e*G,U+=e*Z,d+=e*q,E+=e*V,x+=e*X,M+=e*D,m+=e*j,B+=e*H,S+=e*J,K+=e*Q,w+=(e=t[10])*P,p+=e*N,b+=e*O,g+=e*C,_+=e*F,A+=e*I,U+=e*G,d+=e*Z,E+=e*q,x+=e*V,M+=e*X,m+=e*D,B+=e*j,S+=e*H,K+=e*J,Y+=e*Q,p+=(e=t[11])*P,b+=e*N,g+=e*O,_+=e*C,A+=e*F,U+=e*I,d+=e*G,E+=e*Z,x+=e*q,M+=e*V,m+=e*X,B+=e*D,S+=e*j,K+=e*H,Y+=e*J,k+=e*Q,b+=(e=t[12])*P,g+=e*N,_+=e*O,A+=e*C,U+=e*F,d+=e*I,E+=e*G,x+=e*Z,M+=e*q,m+=e*V,B+=e*X,S+=e*D,K+=e*j,Y+=e*H,k+=e*J,T+=e*Q,g+=(e=t[13])*P,_+=e*N,A+=e*O,U+=e*C,d+=e*F,E+=e*I,x+=e*G,M+=e*Z,m+=e*q,B+=e*V,S+=e*X,K+=e*D,Y+=e*j,k+=e*H,T+=e*J,L+=e*Q,_+=(e=t[14])*P,A+=e*N,U+=e*O,d+=e*C,E+=e*F,x+=e*I,M+=e*G,m+=e*Z,B+=e*q,S+=e*V,K+=e*X,Y+=e*D,k+=e*j,T+=e*H,L+=e*J,z+=e*Q,A+=(e=t[15])*P,h+=38*(d+=e*O),a+=38*(E+=e*C),f+=38*(x+=e*F),s+=38*(M+=e*I),u+=38*(m+=e*G),c+=38*(B+=e*Z),y+=38*(S+=e*q),l+=38*(K+=e*V),v+=38*(Y+=e*X),w+=38*(k+=e*D),p+=38*(T+=e*j),b+=38*(L+=e*H),g+=38*(z+=e*J),_+=38*(R+=e*Q),i=(e=(i+=38*(U+=e*N))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),i=(e=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),i+=o-1+37*(o-1),r[0]=i,r[1]=h,r[2]=a,r[3]=f,r[4]=s,r[5]=u,r[6]=c,r[7]=y,r[8]=l,r[9]=v,r[10]=w,r[11]=p,r[12]=b,r[13]=g,r[14]=_,r[15]=A}function C(r,t){O(r,t,t)}function F(r,n){var e,o=t();for(e=0;e<16;e++)o[e]=n[e];for(e=253;e>=0;e--)C(o,o),2!==e&&4!==e&&O(o,o,n);for(e=0;e<16;e++)r[e]=o[e]}function I(r,n,e){var o,i,h=new Uint8Array(32),f=new Float64Array(80),s=t(),u=t(),c=t(),y=t(),l=t(),v=t();for(i=0;i<31;i++)h[i]=n[i];for(h[31]=127&n[31]|64,h[0]&=248,R(f,e),i=0;i<16;i++)u[i]=f[i],y[i]=s[i]=c[i]=0;for(s[0]=y[0]=1,i=254;i>=0;--i)k(s,u,o=h[i>>>3]>>>(7&i)&1),k(c,y,o),P(l,s,c),N(s,s,c),P(c,u,y),N(u,u,y),C(y,l),C(v,s),O(s,c,s),O(c,u,l),P(l,s,c),N(s,s,c),C(u,s),N(c,y,v),O(s,c,a),P(s,s,y),O(c,c,s),O(s,y,v),O(y,u,f),C(u,l),k(s,u,o),k(c,y,o);for(i=0;i<16;i++)f[i+16]=s[i],f[i+32]=c[i],f[i+48]=u[i],f[i+64]=y[i];var w=f.subarray(32),p=f.subarray(16);return F(w,w),O(p,p,w),T(r,p),0}function G(r,t){return I(r,t,o)}function Z(r,t){return n(t,32),G(r,t)}function q(r,t,n){var o=new Uint8Array(32);return I(o,n,t),g(r,e,o,_)}x.prototype.blocks=function(r,t,n){for(var e,o,i,h,a,f,s,u,c,y,l,v,w,p,b,g,_,A,U,d=this.fin?0:2048,E=this.h[0],x=this.h[1],M=this.h[2],m=this.h[3],B=this.h[4],S=this.h[5],K=this.h[6],Y=this.h[7],k=this.h[8],T=this.h[9],L=this.r[0],z=this.r[1],R=this.r[2],P=this.r[3],N=this.r[4],O=this.r[5],C=this.r[6],F=this.r[7],I=this.r[8],G=this.r[9];n>=16;)y=c=0,y+=(E+=8191&(e=255&r[t+0]|(255&r[t+1])<<8))*L,y+=(x+=8191&(e>>>13|(o=255&r[t+2]|(255&r[t+3])<<8)<<3))*(5*G),y+=(M+=8191&(o>>>10|(i=255&r[t+4]|(255&r[t+5])<<8)<<6))*(5*I),y+=(m+=8191&(i>>>7|(h=255&r[t+6]|(255&r[t+7])<<8)<<9))*(5*F),c=(y+=(B+=8191&(h>>>4|(a=255&r[t+8]|(255&r[t+9])<<8)<<12))*(5*C))>>>13,y&=8191,y+=(S+=a>>>1&8191)*(5*O),y+=(K+=8191&(a>>>14|(f=255&r[t+10]|(255&r[t+11])<<8)<<2))*(5*N),y+=(Y+=8191&(f>>>11|(s=255&r[t+12]|(255&r[t+13])<<8)<<5))*(5*P),y+=(k+=8191&(s>>>8|(u=255&r[t+14]|(255&r[t+15])<<8)<<8))*(5*R),l=c+=(y+=(T+=u>>>5|d)*(5*z))>>>13,l+=E*z,l+=x*L,l+=M*(5*G),l+=m*(5*I),c=(l+=B*(5*F))>>>13,l&=8191,l+=S*(5*C),l+=K*(5*O),l+=Y*(5*N),l+=k*(5*P),c+=(l+=T*(5*R))>>>13,l&=8191,v=c,v+=E*R,v+=x*z,v+=M*L,v+=m*(5*G),c=(v+=B*(5*I))>>>13,v&=8191,v+=S*(5*F),v+=K*(5*C),v+=Y*(5*O),v+=k*(5*N),w=c+=(v+=T*(5*P))>>>13,w+=E*P,w+=x*R,w+=M*z,w+=m*L,c=(w+=B*(5*G))>>>13,w&=8191,w+=S*(5*I),w+=K*(5*F),w+=Y*(5*C),w+=k*(5*O),p=c+=(w+=T*(5*N))>>>13,p+=E*N,p+=x*P,p+=M*R,p+=m*z,c=(p+=B*L)>>>13,p&=8191,p+=S*(5*G),p+=K*(5*I),p+=Y*(5*F),p+=k*(5*C),b=c+=(p+=T*(5*O))>>>13,b+=E*O,b+=x*N,b+=M*P,b+=m*R,c=(b+=B*z)>>>13,b&=8191,b+=S*L,b+=K*(5*G),b+=Y*(5*I),b+=k*(5*F),g=c+=(b+=T*(5*C))>>>13,g+=E*C,g+=x*O,g+=M*N,g+=m*P,c=(g+=B*R)>>>13,g&=8191,g+=S*z,g+=K*L,g+=Y*(5*G),g+=k*(5*I),_=c+=(g+=T*(5*F))>>>13,_+=E*F,_+=x*C,_+=M*O,_+=m*N,c=(_+=B*P)>>>13,_&=8191,_+=S*R,_+=K*z,_+=Y*L,_+=k*(5*G),A=c+=(_+=T*(5*I))>>>13,A+=E*I,A+=x*F,A+=M*C,A+=m*O,c=(A+=B*N)>>>13,A&=8191,A+=S*P,A+=K*R,A+=Y*z,A+=k*L,U=c+=(A+=T*(5*G))>>>13,U+=E*G,U+=x*I,U+=M*F,U+=m*C,c=(U+=B*O)>>>13,U&=8191,U+=S*N,U+=K*P,U+=Y*R,U+=k*z,E=y=8191&(c=(c=((c+=(U+=T*L)>>>13)<<2)+c|0)+(y&=8191)|0),x=l+=c>>>=13,M=v&=8191,m=w&=8191,B=p&=8191,S=b&=8191,K=g&=8191,Y=_&=8191,k=A&=8191,T=U&=8191,t+=16,n-=16;this.h[0]=E,this.h[1]=x,this.h[2]=M,this.h[3]=m,this.h[4]=B,this.h[5]=S,this.h[6]=K,this.h[7]=Y,this.h[8]=k,this.h[9]=T},x.prototype.finish=function(r,t){var n,e,o,i,h=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,h[0]=this.h[0]+5,n=h[0]>>>13,h[0]&=8191,i=1;i<10;i++)h[i]=this.h[i]+n,n=h[i]>>>13,h[i]&=8191;for(h[9]-=8192,e=(1^n)-1,i=0;i<10;i++)h[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|h[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},x.prototype.update=function(r,t,n){var e,o;if(this.leftover){for((o=16-this.leftover)>n&&(o=n),e=0;e=16&&(o=n-n%16,this.blocks(r,t,o),t+=o,n-=o),n){for(e=0;e=128;){for(d=0;d<16;d++)E=8*d+H,Y[d]=n[E+0]<<24|n[E+1]<<16|n[E+2]<<8|n[E+3],k[d]=n[E+4]<<24|n[E+5]<<16|n[E+6]<<8|n[E+7];for(d=0;d<80;d++)if(o=T,i=L,h=z,a=R,f=P,s=N,u=O,C,y=F,l=I,v=G,w=Z,p=q,b=V,g=X,j,m=65535&(M=j),B=M>>>16,S=65535&(x=C),K=x>>>16,m+=65535&(M=(q>>>14|P<<18)^(q>>>18|P<<14)^(P>>>9|q<<23)),B+=M>>>16,S+=65535&(x=(P>>>14|q<<18)^(P>>>18|q<<14)^(q>>>9|P<<23)),K+=x>>>16,m+=65535&(M=q&V^~q&X),B+=M>>>16,S+=65535&(x=P&N^~P&O),K+=x>>>16,x=D[2*d],m+=65535&(M=D[2*d+1]),B+=M>>>16,S+=65535&x,K+=x>>>16,x=Y[d%16],B+=(M=k[d%16])>>>16,S+=65535&x,K+=x>>>16,S+=(B+=(m+=65535&M)>>>16)>>>16,m=65535&(M=U=65535&m|B<<16),B=M>>>16,S=65535&(x=A=65535&S|(K+=S>>>16)<<16),K=x>>>16,m+=65535&(M=(F>>>28|T<<4)^(T>>>2|F<<30)^(T>>>7|F<<25)),B+=M>>>16,S+=65535&(x=(T>>>28|F<<4)^(F>>>2|T<<30)^(F>>>7|T<<25)),K+=x>>>16,B+=(M=F&I^F&G^I&G)>>>16,S+=65535&(x=T&L^T&z^L&z),K+=x>>>16,c=65535&(S+=(B+=(m+=65535&M)>>>16)>>>16)|(K+=S>>>16)<<16,_=65535&m|B<<16,m=65535&(M=w),B=M>>>16,S=65535&(x=a),K=x>>>16,B+=(M=U)>>>16,S+=65535&(x=A),K+=x>>>16,L=o,z=i,R=h,P=a=65535&(S+=(B+=(m+=65535&M)>>>16)>>>16)|(K+=S>>>16)<<16,N=f,O=s,C=u,T=c,I=y,G=l,Z=v,q=w=65535&m|B<<16,V=p,X=b,j=g,F=_,d%16==15)for(E=0;E<16;E++)x=Y[E],m=65535&(M=k[E]),B=M>>>16,S=65535&x,K=x>>>16,x=Y[(E+9)%16],m+=65535&(M=k[(E+9)%16]),B+=M>>>16,S+=65535&x,K+=x>>>16,A=Y[(E+1)%16],m+=65535&(M=((U=k[(E+1)%16])>>>1|A<<31)^(U>>>8|A<<24)^(U>>>7|A<<25)),B+=M>>>16,S+=65535&(x=(A>>>1|U<<31)^(A>>>8|U<<24)^A>>>7),K+=x>>>16,A=Y[(E+14)%16],B+=(M=((U=k[(E+14)%16])>>>19|A<<13)^(A>>>29|U<<3)^(U>>>6|A<<26))>>>16,S+=65535&(x=(A>>>19|U<<13)^(U>>>29|A<<3)^A>>>6),K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,Y[E]=65535&S|K<<16,k[E]=65535&m|B<<16;m=65535&(M=F),B=M>>>16,S=65535&(x=T),K=x>>>16,x=r[0],B+=(M=t[0])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[0]=T=65535&S|K<<16,t[0]=F=65535&m|B<<16,m=65535&(M=I),B=M>>>16,S=65535&(x=L),K=x>>>16,x=r[1],B+=(M=t[1])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[1]=L=65535&S|K<<16,t[1]=I=65535&m|B<<16,m=65535&(M=G),B=M>>>16,S=65535&(x=z),K=x>>>16,x=r[2],B+=(M=t[2])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[2]=z=65535&S|K<<16,t[2]=G=65535&m|B<<16,m=65535&(M=Z),B=M>>>16,S=65535&(x=R),K=x>>>16,x=r[3],B+=(M=t[3])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[3]=R=65535&S|K<<16,t[3]=Z=65535&m|B<<16,m=65535&(M=q),B=M>>>16,S=65535&(x=P),K=x>>>16,x=r[4],B+=(M=t[4])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[4]=P=65535&S|K<<16,t[4]=q=65535&m|B<<16,m=65535&(M=V),B=M>>>16,S=65535&(x=N),K=x>>>16,x=r[5],B+=(M=t[5])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[5]=N=65535&S|K<<16,t[5]=V=65535&m|B<<16,m=65535&(M=X),B=M>>>16,S=65535&(x=O),K=x>>>16,x=r[6],B+=(M=t[6])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[6]=O=65535&S|K<<16,t[6]=X=65535&m|B<<16,m=65535&(M=j),B=M>>>16,S=65535&(x=C),K=x>>>16,x=r[7],B+=(M=t[7])>>>16,S+=65535&x,K+=x>>>16,K+=(S+=(B+=(m+=65535&M)>>>16)>>>16)>>>16,r[7]=C=65535&S|K<<16,t[7]=j=65535&m|B<<16,H+=128,e-=128}return e}function H(r,t,n){var e,o=new Int32Array(8),i=new Int32Array(8),h=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,j(o,i,t,n),n%=128,e=0;e=0;--o)Q(r,t,e=n[o/8|0]>>(7&o)&1),J(t,r),J(r,r),Q(r,t,e)}function rr(r,n){var e=[t(),t(),t(),t()];K(e[0],u),K(e[1],c),K(e[2],h),O(e[3],u,c),$(r,e,n)}function tr(r,e,o){var i,h=new Uint8Array(64),a=[t(),t(),t(),t()];for(o||n(e,32),H(h,e,32),h[0]&=248,h[31]&=127,h[31]|=64,rr(a,h),W(r,a),i=0;i<32;i++)e[i+32]=r[i];return 0}var nr=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function er(r,t){var n,e,o,i;for(e=63;e>=32;--e){for(n=0,o=e-32,i=e-12;o>8,t[o]-=256*n;t[o]+=n,t[e]=0}for(n=0,o=0;o<32;o++)t[o]+=n-(t[31]>>4)*nr[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*nr[o];for(e=0;e<32;e++)t[e+1]+=t[e]>>8,r[e]=255&t[e]}function or(r){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=r[t];for(t=0;t<64;t++)r[t]=0;er(r,n)}function ir(r,n,e,o){var i,h,a=new Uint8Array(64),f=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[t(),t(),t(),t()];H(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var y=e+64;for(i=0;i=0;e--)C(o,o),1!==e&&O(o,o,n);for(e=0;e<16;e++)r[e]=o[e]}(e,e),O(e,e,a),O(e,e,s),O(e,e,s),O(r[0],e,s),C(o,r[0]),O(o,o,s),L(o,a)&&O(r[0],r[0],y),C(o,r[0]),O(o,o,s),L(o,a)?-1:(z(r[0])===n[31]>>7&&N(r[0],i,r[0]),O(r[3],r[0],r[1]),0)}function ar(r,n,e,o){var i,h=new Uint8Array(32),a=new Uint8Array(64),f=[t(),t(),t(),t()],s=[t(),t(),t(),t()];if(-1,e<64)return-1;if(hr(s,o))return-1;for(i=0;i=0},r.sign.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(64);return tr(r,t),{publicKey:r,secretKey:t}},r.sign.keyPair.fromSecretKey=function(r){if(vr(r),64!==r.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),n=0;n=i)return e;switch(e){case"%s":return String(n[t++]);case"%d":return Number(n[t++]);case"%j":try{return JSON.stringify(n[t++])}catch(e){return"[Circular]"}default:return e}}),s=n[t];t=3&&(t.depth=arguments[2]),arguments.length>=4&&(t.colors=arguments[3]),isBoolean(r)?t.showHidden=r:r&&exports._extend(t,r),isUndefined(t.showHidden)&&(t.showHidden=!1),isUndefined(t.depth)&&(t.depth=2),isUndefined(t.colors)&&(t.colors=!1),isUndefined(t.customInspect)&&(t.customInspect=!0),t.colors&&(t.stylize=stylizeWithColor),formatValue(t,e,t.depth)}function stylizeWithColor(e,r){var t=inspect.styles[r];return t?"["+inspect.colors[t][0]+"m"+e+"["+inspect.colors[t][1]+"m":e}function stylizeNoColor(e,r){return e}function arrayToHash(e){var r={};return e.forEach(function(e,t){r[e]=!0}),r}function formatValue(e,r,t){if(e.customInspect&&r&&isFunction(r.inspect)&&r.inspect!==exports.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(t,e);return isString(n)||(n=formatValue(e,n,t)),n}var i=formatPrimitive(e,r);if(i)return i;var o=Object.keys(r),s=arrayToHash(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),isError(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return formatError(r);if(0===o.length){if(isFunction(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(isRegExp(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(isDate(r))return e.stylize(Date.prototype.toString.call(r),"date");if(isError(r))return formatError(r)}var c,a="",l=!1,p=["{","}"];(isArray(r)&&(l=!0,p=["[","]"]),isFunction(r))&&(a=" [Function"+(r.name?": "+r.name:"")+"]");return isRegExp(r)&&(a=" "+RegExp.prototype.toString.call(r)),isDate(r)&&(a=" "+Date.prototype.toUTCString.call(r)),isError(r)&&(a=" "+formatError(r)),0!==o.length||l&&0!=r.length?t<0?isRegExp(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),c=l?formatArray(e,r,t,s,o):o.map(function(n){return formatProperty(e,r,t,s,n,l)}),e.seen.pop(),reduceToSingleString(c,a,p)):p[0]+a+p[1]}function formatPrimitive(e,r){if(isUndefined(r))return e.stylize("undefined","undefined");if(isString(r)){var t="'"+JSON.stringify(r).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(t,"string")}return isNumber(r)?e.stylize(""+r,"number"):isBoolean(r)?e.stylize(""+r,"boolean"):isNull(r)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,r,t,n,i){for(var o=[],s=0,u=r.length;s-1&&(u=o?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n")):u=e.stylize("[Circular]","special")),isUndefined(s)){if(o&&i.match(/^\d+$/))return u;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function reduceToSingleString(e,r,t){return e.reduce(function(e,r){return 0,r.indexOf("\n")>=0&&0,e+r.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?t[0]+(""===r?"":r+"\n ")+" "+e.join(",\n ")+" "+t[1]:t[0]+r+" "+e.join(", ")+" "+t[1]}function isArray(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isSymbol(e){return"symbol"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject(e)&&"[object RegExp]"===objectToString(e)}function isObject(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject(e)&&"[object Date]"===objectToString(e)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString(e){return Object.prototype.toString.call(e)}function pad(e){return e<10?"0"+e.toString(10):e.toString(10)}exports.debuglog=function(e){if(isUndefined(debugEnviron)&&(debugEnviron=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!debugs[e])if(new RegExp("\\b"+e+"\\b","i").test(debugEnviron)){var r=process.pid;debugs[e]=function(){var t=exports.format.apply(exports,arguments);console.error("%s %d: %s",e,r,t)}}else debugs[e]=function(){};return debugs[e]},exports.inspect=inspect,inspect.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=isNullOrUndefined,exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=isSymbol,exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=isPrimitive,exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function timestamp(){var e=new Date,r=[pad(e.getHours()),pad(e.getMinutes()),pad(e.getSeconds())].join(":");return[e.getDate(),months[e.getMonth()],r].join(" ")}function hasOwnProperty(e,r){return Object.prototype.hasOwnProperty.call(e,r)}exports.log=function(){console.log("%s - %s",timestamp(),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(e,r){if(!r||!isObject(r))return e;for(var t=Object.keys(r),n=t.length;n--;)e[t[n]]=r[t[n]];return e}; }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":85,"_process":63,"inherits":57}]},{},[1]); +},{"./support/isBuffer":66,"_process":55,"inherits":49}]},{},[1]); diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 7239c207e9..4c65e2e7c0 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -42,6 +42,27 @@ * [InMemorySigner](classes/_signer_.inmemorysigner.md) * [Signer](classes/_signer_.signer.md) * ["transaction"](modules/_transaction_.md) + * [KeyType](enums/_transaction_.keytype.md) + * [AccessKey](classes/_transaction_.accesskey.md) + * [AccessKeyPermission](classes/_transaction_.accesskeypermission.md) + * [Action](classes/_transaction_.action.md) + * [AddKey](classes/_transaction_.addkey.md) + * [Assignable](classes/_transaction_.assignable.md) + * [CreateAccount](classes/_transaction_.createaccount.md) + * [DeleteAccount](classes/_transaction_.deleteaccount.md) + * [DeleteKey](classes/_transaction_.deletekey.md) + * [DeployContract](classes/_transaction_.deploycontract.md) + * [Enum](classes/_transaction_.enum.md) + * [FullAccessPermission](classes/_transaction_.fullaccesspermission.md) + * [FunctionCall](classes/_transaction_.functioncall.md) + * [FunctionCallPermission](classes/_transaction_.functioncallpermission.md) + * [IAction](classes/_transaction_.iaction.md) + * [PublicKey](classes/_transaction_.publickey.md) + * [Signature](classes/_transaction_.signature.md) + * [SignedTransaction](classes/_transaction_.signedtransaction.md) + * [Stake](classes/_transaction_.stake.md) + * [Transaction](classes/_transaction_.transaction.md) + * [Transfer](classes/_transaction_.transfer.md) * ["utils/index"](modules/_utils_index_.md) * ["utils/key_pair"](modules/_utils_key_pair_.md) * [KeyPair](classes/_utils_key_pair_.keypair.md) @@ -50,6 +71,8 @@ * ["utils/network"](modules/_utils_network_.md) * [Network](interfaces/_utils_network_.network.md) * ["utils/serialize"](modules/_utils_serialize_.md) + * [BinaryReader](classes/_utils_serialize_.binaryreader.md) + * [BinaryWriter](classes/_utils_serialize_.binarywriter.md) * ["utils/web"](modules/_utils_web_.md) * [ConnectionInfo](interfaces/_utils_web_.connectioninfo.md) * ["wallet-account"](modules/_wallet_account_.md) diff --git a/docs/classes/_account_.account.md b/docs/classes/_account_.account.md index 03e9913d28..42308acdf0 100644 --- a/docs/classes/_account_.account.md +++ b/docs/classes/_account_.account.md @@ -12,7 +12,7 @@ ⊕ **new Account**(connection: *[Connection](_connection_.connection.md)*, accountId: *`string`*): [Account](_account_.account.md) -*Defined in [account.ts:46](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L46)* +*Defined in [account.ts:45](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L45)* **Parameters:** @@ -27,13 +27,22 @@ ___ # Properties + + +## `` _accessKey + +**● _accessKey**: *[AccessKey](_transaction_.accesskey.md)* + +*Defined in [account.ts:40](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L40)* + +___ ## `` _ready **● _ready**: *`Promise`<`void`>* -*Defined in [account.ts:43](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L43)* +*Defined in [account.ts:42](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L42)* ___ @@ -42,7 +51,7 @@ ___ **● _state**: *[AccountState](../interfaces/_account_.accountstate.md)* -*Defined in [account.ts:41](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L41)* +*Defined in [account.ts:39](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L39)* ___ @@ -51,7 +60,7 @@ ___ **● accountId**: *`string`* -*Defined in [account.ts:40](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L40)* +*Defined in [account.ts:38](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L38)* ___ @@ -60,7 +69,7 @@ ___ **● connection**: *[Connection](_connection_.connection.md)* -*Defined in [account.ts:39](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L39)* +*Defined in [account.ts:37](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L37)* ___ @@ -72,7 +81,7 @@ ___ **get ready**(): `Promise`<`void`> -*Defined in [account.ts:44](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L44)* +*Defined in [account.ts:43](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L43)* **Returns:** `Promise`<`void`> @@ -84,9 +93,9 @@ ___ ## addKey -▸ **addKey**(publicKey: *`string`*, contractId?: *`string`*, methodName?: *`string`*, balanceOwner?: *`string`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **addKey**(publicKey: *`string`*, contractId?: *`string`*, methodName?: *`string`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:155](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L155)* +*Defined in [account.ts:150](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L150)* **Parameters:** @@ -95,7 +104,6 @@ ___ | publicKey | `string` | | `Optional` contractId | `string` | | `Optional` methodName | `string` | -| `Optional` balanceOwner | `string` | | `Optional` amount | `BN` | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -107,7 +115,7 @@ ___ ▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:134](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L134)* +*Defined in [account.ts:133](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L133)* **Parameters:** @@ -126,7 +134,7 @@ ___ ▸ **createAndDeployContract**(contractId: *`string`*, publicKey: *`string`*, data: *`Uint8Array`*, amount: *`BN`*): `Promise`<[Account](_account_.account.md)> -*Defined in [account.ts:120](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L120)* +*Defined in [account.ts:121](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L121)* **Parameters:** @@ -146,7 +154,7 @@ ___ ▸ **deleteKey**(publicKey: *`string`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:162](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L162)* +*Defined in [account.ts:160](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L160)* **Parameters:** @@ -163,7 +171,7 @@ ___ ▸ **deployContract**(data: *`Uint8Array`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:140](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L140)* +*Defined in [account.ts:138](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L138)* **Parameters:** @@ -180,7 +188,7 @@ ___ ▸ **fetchState**(): `Promise`<`void`> -*Defined in [account.ts:53](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L53)* +*Defined in [account.ts:52](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L52)* **Returns:** `Promise`<`void`> @@ -189,9 +197,9 @@ ___ ## functionCall -▸ **functionCall**(contractId: *`string`*, methodName: *`string`*, args: *`any`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **functionCall**(contractId: *`string`*, methodName: *`string`*, args: *`any`*, gas: *`number`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:146](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L146)* +*Defined in [account.ts:142](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L142)* **Parameters:** @@ -200,10 +208,22 @@ ___ | contractId | `string` | | methodName | `string` | | args | `any` | +| gas | `number` | | `Optional` amount | `BN` | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +___ + + +## getAccessKeys + +▸ **getAccessKeys**(): `Promise`<`any`> + +*Defined in [account.ts:177](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L177)* + +**Returns:** `Promise`<`any`> + ___ @@ -211,7 +231,7 @@ ___ ▸ **getAccountDetails**(): `Promise`<`any`> -*Defined in [account.ts:182](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L182)* +*Defined in [account.ts:182](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L182)* **Returns:** `Promise`<`any`> @@ -222,7 +242,7 @@ ___ ▸ **printLogs**(contractId: *`string`*, logs: *`string`[]*): `void` -*Defined in [account.ts:65](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L65)* +*Defined in [account.ts:67](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L67)* **Parameters:** @@ -240,7 +260,7 @@ ___ ▸ **retryTxResult**(txHash: *`Uint8Array`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:71](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L71)* +*Defined in [account.ts:73](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L73)* **Parameters:** @@ -255,15 +275,15 @@ ___ ## sendMoney -▸ **sendMoney**(receiver: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **sendMoney**(receiverId: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:128](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L128)* +*Defined in [account.ts:129](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L129)* **Parameters:** | Name | Type | | ------ | ------ | -| receiver | `string` | +| receiverId | `string` | | amount | `BN` | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -273,15 +293,16 @@ ___ ## `` signAndSendTransaction -▸ **signAndSendTransaction**(transaction: *`any`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **signAndSendTransaction**(receiverId: *`string`*, actions: *[Action](_transaction_.action.md)[]*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:86](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L86)* +*Defined in [account.ts:88](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L88)* **Parameters:** | Name | Type | | ------ | ------ | -| transaction | `any` | +| receiverId | `string` | +| actions | [Action](_transaction_.action.md)[] | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -292,7 +313,7 @@ ___ ▸ **stake**(publicKey: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:168](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L168)* +*Defined in [account.ts:164](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L164)* **Parameters:** @@ -310,7 +331,7 @@ ___ ▸ **state**(): `Promise`<[AccountState](../interfaces/_account_.accountstate.md)> -*Defined in [account.ts:60](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L60)* +*Defined in [account.ts:62](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L62)* **Returns:** `Promise`<[AccountState](../interfaces/_account_.accountstate.md)> @@ -321,7 +342,7 @@ ___ ▸ **viewFunction**(contractId: *`string`*, methodName: *`string`*, args: *`any`*): `Promise`<`any`> -*Defined in [account.ts:174](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L174)* +*Defined in [account.ts:168](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L168)* **Parameters:** diff --git a/docs/classes/_account_creator_.accountcreator.md b/docs/classes/_account_creator_.accountcreator.md index cf9d6dcc5e..b6ce9027a1 100644 --- a/docs/classes/_account_creator_.accountcreator.md +++ b/docs/classes/_account_creator_.accountcreator.md @@ -18,7 +18,7 @@ Account creator provides interface to specific implementation to acutally create ▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*): `Promise`<`void`> -*Defined in [account_creator.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L10)* +*Defined in [account_creator.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L10)* **Parameters:** diff --git a/docs/classes/_account_creator_.localaccountcreator.md b/docs/classes/_account_creator_.localaccountcreator.md index 0d13e4ac75..467803559a 100644 --- a/docs/classes/_account_creator_.localaccountcreator.md +++ b/docs/classes/_account_creator_.localaccountcreator.md @@ -14,7 +14,7 @@ ⊕ **new LocalAccountCreator**(masterAccount: *[Account](_account_.account.md)*, initialBalance: *`BN`*): [LocalAccountCreator](_account_creator_.localaccountcreator.md) -*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L15)* +*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L15)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● initialBalance**: *`BN`* -*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L15)* +*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L15)* ___ @@ -44,7 +44,7 @@ ___ **● masterAccount**: *[Account](_account_.account.md)* -*Defined in [account_creator.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L14)* +*Defined in [account_creator.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L14)* ___ @@ -58,7 +58,7 @@ ___ *Overrides [AccountCreator](_account_creator_.accountcreator.md).[createAccount](_account_creator_.accountcreator.md#createaccount)* -*Defined in [account_creator.ts:23](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L23)* +*Defined in [account_creator.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L23)* **Parameters:** diff --git a/docs/classes/_account_creator_.urlaccountcreator.md b/docs/classes/_account_creator_.urlaccountcreator.md index 414bc2510e..39ef2f1d9a 100644 --- a/docs/classes/_account_creator_.urlaccountcreator.md +++ b/docs/classes/_account_creator_.urlaccountcreator.md @@ -14,7 +14,7 @@ ⊕ **new UrlAccountCreator**(connection: *[Connection](_connection_.connection.md)*, helperUrl: *`string`*): [UrlAccountCreator](_account_creator_.urlaccountcreator.md) -*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L31)* +*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L31)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● connection**: *[Connection](_connection_.connection.md)* -*Defined in [account_creator.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L30)* +*Defined in [account_creator.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L30)* ___ @@ -44,7 +44,7 @@ ___ **● helperConnection**: *[ConnectionInfo](../interfaces/_utils_web_.connectioninfo.md)* -*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L31)* +*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L31)* ___ @@ -58,7 +58,7 @@ ___ *Overrides [AccountCreator](_account_creator_.accountcreator.md).[createAccount](_account_creator_.accountcreator.md#createaccount)* -*Defined in [account_creator.ts:39](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account_creator.ts#L39)* +*Defined in [account_creator.ts:39](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account_creator.ts#L39)* **Parameters:** diff --git a/docs/classes/_connection_.connection.md b/docs/classes/_connection_.connection.md index cb4202754f..a9ac755150 100644 --- a/docs/classes/_connection_.connection.md +++ b/docs/classes/_connection_.connection.md @@ -12,7 +12,7 @@ ⊕ **new Connection**(networkId: *`string`*, provider: *[Provider](_providers_provider_.provider.md)*, signer: *[Signer](_signer_.signer.md)*): [Connection](_connection_.connection.md) -*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L25)* +*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L25)* **Parameters:** @@ -34,7 +34,7 @@ ___ **● networkId**: *`string`* -*Defined in [connection.ts:23](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L23)* +*Defined in [connection.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L23)* ___ @@ -43,7 +43,7 @@ ___ **● provider**: *[Provider](_providers_provider_.provider.md)* -*Defined in [connection.ts:24](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L24)* +*Defined in [connection.ts:24](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L24)* ___ @@ -52,7 +52,7 @@ ___ **● signer**: *[Signer](_signer_.signer.md)* -*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L25)* +*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L25)* ___ @@ -64,7 +64,7 @@ ___ ▸ **fromConfig**(config: *`any`*): [Connection](_connection_.connection.md) -*Defined in [connection.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L33)* +*Defined in [connection.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L33)* **Parameters:** diff --git a/docs/classes/_contract_.contract.md b/docs/classes/_contract_.contract.md index d832c5c88d..d326b79302 100644 --- a/docs/classes/_contract_.contract.md +++ b/docs/classes/_contract_.contract.md @@ -12,7 +12,7 @@ ⊕ **new Contract**(account: *[Account](_account_.account.md)*, contractId: *`string`*, options: *`object`*): [Contract](_contract_.contract.md) -*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/contract.ts#L8)* +*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/contract.ts#L8)* **Parameters:** @@ -39,7 +39,7 @@ ___ **● account**: *[Account](_account_.account.md)* -*Defined in [contract.ts:7](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/contract.ts#L7)* +*Defined in [contract.ts:7](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/contract.ts#L7)* ___ @@ -48,7 +48,7 @@ ___ **● contractId**: *`string`* -*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/contract.ts#L8)* +*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/contract.ts#L8)* ___ diff --git a/docs/classes/_key_stores_browser_local_storage_key_store_.browserlocalstoragekeystore.md b/docs/classes/_key_stores_browser_local_storage_key_store_.browserlocalstoragekeystore.md index 883f374178..ed227640eb 100644 --- a/docs/classes/_key_stores_browser_local_storage_key_store_.browserlocalstoragekeystore.md +++ b/docs/classes/_key_stores_browser_local_storage_key_store_.browserlocalstoragekeystore.md @@ -14,7 +14,7 @@ ⊕ **new BrowserLocalStorageKeyStore**(localStorage?: *`any`*, prefix?: *`string`*): [BrowserLocalStorageKeyStore](_key_stores_browser_local_storage_key_store_.browserlocalstoragekeystore.md) -*Defined in [key_stores/browser_local_storage_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L10)* +*Defined in [key_stores/browser_local_storage_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L10)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● localStorage**: *`any`* -*Defined in [key_stores/browser_local_storage_key_store.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L9)* +*Defined in [key_stores/browser_local_storage_key_store.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L9)* ___ @@ -44,7 +44,7 @@ ___ **● prefix**: *`string`* -*Defined in [key_stores/browser_local_storage_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L10)* +*Defined in [key_stores/browser_local_storage_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L10)* ___ @@ -58,7 +58,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[clear](_key_stores_keystore_.keystore.md#clear)* -*Defined in [key_stores/browser_local_storage_key_store.ts:34](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L34)* +*Defined in [key_stores/browser_local_storage_key_store.ts:34](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L34)* **Returns:** `Promise`<`void`> @@ -71,7 +71,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getAccounts](_key_stores_keystore_.keystore.md#getaccounts)* -*Defined in [key_stores/browser_local_storage_key_store.ts:53](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L53)* +*Defined in [key_stores/browser_local_storage_key_store.ts:53](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L53)* **Parameters:** @@ -90,7 +90,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getKey](_key_stores_keystore_.keystore.md#getkey)* -*Defined in [key_stores/browser_local_storage_key_store.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L22)* +*Defined in [key_stores/browser_local_storage_key_store.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L22)* **Parameters:** @@ -110,7 +110,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getNetworks](_key_stores_keystore_.keystore.md#getnetworks)* -*Defined in [key_stores/browser_local_storage_key_store.ts:42](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L42)* +*Defined in [key_stores/browser_local_storage_key_store.ts:42](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L42)* **Returns:** `Promise`<`string`[]> @@ -123,7 +123,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[removeKey](_key_stores_keystore_.keystore.md#removekey)* -*Defined in [key_stores/browser_local_storage_key_store.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L30)* +*Defined in [key_stores/browser_local_storage_key_store.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L30)* **Parameters:** @@ -143,7 +143,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[setKey](_key_stores_keystore_.keystore.md#setkey)* -*Defined in [key_stores/browser_local_storage_key_store.ts:18](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L18)* +*Defined in [key_stores/browser_local_storage_key_store.ts:18](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L18)* **Parameters:** @@ -162,7 +162,7 @@ ___ ▸ **storageKeyForSecretKey**(networkId: *`string`*, accountId: *`string`*): `string` -*Defined in [key_stores/browser_local_storage_key_store.ts:66](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L66)* +*Defined in [key_stores/browser_local_storage_key_store.ts:66](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L66)* **Parameters:** @@ -180,7 +180,7 @@ ___ ▸ **storageKeys**(): `IterableIterator`<`string`> -*Defined in [key_stores/browser_local_storage_key_store.ts:70](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L70)* +*Defined in [key_stores/browser_local_storage_key_store.ts:70](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L70)* **Returns:** `IterableIterator`<`string`> diff --git a/docs/classes/_key_stores_in_memory_key_store_.inmemorykeystore.md b/docs/classes/_key_stores_in_memory_key_store_.inmemorykeystore.md index a38471fede..8474fed93a 100644 --- a/docs/classes/_key_stores_in_memory_key_store_.inmemorykeystore.md +++ b/docs/classes/_key_stores_in_memory_key_store_.inmemorykeystore.md @@ -16,7 +16,7 @@ Simple in-memory keystore for testing purposes. ⊕ **new InMemoryKeyStore**(): [InMemoryKeyStore](_key_stores_in_memory_key_store_.inmemorykeystore.md) -*Defined in [key_stores/in_memory_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L10)* +*Defined in [key_stores/in_memory_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L10)* **Returns:** [InMemoryKeyStore](_key_stores_in_memory_key_store_.inmemorykeystore.md) @@ -30,7 +30,7 @@ ___ **● keys**: *`object`* -*Defined in [key_stores/in_memory_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L10)* +*Defined in [key_stores/in_memory_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L10)* #### Type declaration @@ -48,7 +48,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[clear](_key_stores_keystore_.keystore.md#clear)* -*Defined in [key_stores/in_memory_key_store.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L33)* +*Defined in [key_stores/in_memory_key_store.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L33)* **Returns:** `Promise`<`void`> @@ -61,7 +61,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getAccounts](_key_stores_keystore_.keystore.md#getaccounts)* -*Defined in [key_stores/in_memory_key_store.ts:46](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L46)* +*Defined in [key_stores/in_memory_key_store.ts:46](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L46)* **Parameters:** @@ -80,7 +80,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getKey](_key_stores_keystore_.keystore.md#getkey)* -*Defined in [key_stores/in_memory_key_store.ts:21](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L21)* +*Defined in [key_stores/in_memory_key_store.ts:21](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L21)* **Parameters:** @@ -100,7 +100,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getNetworks](_key_stores_keystore_.keystore.md#getnetworks)* -*Defined in [key_stores/in_memory_key_store.ts:37](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L37)* +*Defined in [key_stores/in_memory_key_store.ts:37](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L37)* **Returns:** `Promise`<`string`[]> @@ -113,7 +113,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[removeKey](_key_stores_keystore_.keystore.md#removekey)* -*Defined in [key_stores/in_memory_key_store.ts:29](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L29)* +*Defined in [key_stores/in_memory_key_store.ts:29](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L29)* **Parameters:** @@ -133,7 +133,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[setKey](_key_stores_keystore_.keystore.md#setkey)* -*Defined in [key_stores/in_memory_key_store.ts:17](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/in_memory_key_store.ts#L17)* +*Defined in [key_stores/in_memory_key_store.ts:17](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/in_memory_key_store.ts#L17)* **Parameters:** diff --git a/docs/classes/_key_stores_keystore_.keystore.md b/docs/classes/_key_stores_keystore_.keystore.md index c895d6f1a9..7ec8a92c99 100644 --- a/docs/classes/_key_stores_keystore_.keystore.md +++ b/docs/classes/_key_stores_keystore_.keystore.md @@ -22,7 +22,7 @@ Key store interface for `InMemorySigner`. ▸ **clear**(): `Promise`<`void`> -*Defined in [key_stores/keystore.ts:12](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L12)* +*Defined in [key_stores/keystore.ts:12](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L12)* **Returns:** `Promise`<`void`> @@ -33,7 +33,7 @@ ___ ▸ **getAccounts**(networkId: *`string`*): `Promise`<`string`[]> -*Defined in [key_stores/keystore.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L14)* +*Defined in [key_stores/keystore.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L14)* **Parameters:** @@ -50,7 +50,7 @@ ___ ▸ **getKey**(networkId: *`string`*, accountId: *`string`*): `Promise`<[KeyPair](_utils_key_pair_.keypair.md)> -*Defined in [key_stores/keystore.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L10)* +*Defined in [key_stores/keystore.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L10)* **Parameters:** @@ -68,7 +68,7 @@ ___ ▸ **getNetworks**(): `Promise`<`string`[]> -*Defined in [key_stores/keystore.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L13)* +*Defined in [key_stores/keystore.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L13)* **Returns:** `Promise`<`string`[]> @@ -79,7 +79,7 @@ ___ ▸ **removeKey**(networkId: *`string`*, accountId: *`string`*): `Promise`<`void`> -*Defined in [key_stores/keystore.ts:11](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L11)* +*Defined in [key_stores/keystore.ts:11](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L11)* **Parameters:** @@ -97,7 +97,7 @@ ___ ▸ **setKey**(networkId: *`string`*, accountId: *`string`*, keyPair: *[KeyPair](_utils_key_pair_.keypair.md)*): `Promise`<`void`> -*Defined in [key_stores/keystore.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/keystore.ts#L9)* +*Defined in [key_stores/keystore.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/keystore.ts#L9)* **Parameters:** diff --git a/docs/classes/_key_stores_merge_key_store_.mergekeystore.md b/docs/classes/_key_stores_merge_key_store_.mergekeystore.md index edf48d5590..3226703bf9 100644 --- a/docs/classes/_key_stores_merge_key_store_.mergekeystore.md +++ b/docs/classes/_key_stores_merge_key_store_.mergekeystore.md @@ -16,7 +16,7 @@ Keystore which can be used to merge multiple key stores into one virtual key sto ⊕ **new MergeKeyStore**(keyStores: *[KeyStore](_key_stores_keystore_.keystore.md)[]*): [MergeKeyStore](_key_stores_merge_key_store_.mergekeystore.md) -*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L10)* +*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L10)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● keyStores**: *[KeyStore](_key_stores_keystore_.keystore.md)[]* -*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L10)* +*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L10)* ___ @@ -50,7 +50,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[clear](_key_stores_keystore_.keystore.md#clear)* -*Defined in [key_stores/merge_key_store.ts:40](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L40)* +*Defined in [key_stores/merge_key_store.ts:40](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L40)* **Returns:** `Promise`<`void`> @@ -63,7 +63,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getAccounts](_key_stores_keystore_.keystore.md#getaccounts)* -*Defined in [key_stores/merge_key_store.ts:56](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L56)* +*Defined in [key_stores/merge_key_store.ts:56](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L56)* **Parameters:** @@ -82,7 +82,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getKey](_key_stores_keystore_.keystore.md#getkey)* -*Defined in [key_stores/merge_key_store.ts:24](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L24)* +*Defined in [key_stores/merge_key_store.ts:24](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L24)* **Parameters:** @@ -102,7 +102,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getNetworks](_key_stores_keystore_.keystore.md#getnetworks)* -*Defined in [key_stores/merge_key_store.ts:46](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L46)* +*Defined in [key_stores/merge_key_store.ts:46](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L46)* **Returns:** `Promise`<`string`[]> @@ -115,7 +115,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[removeKey](_key_stores_keystore_.keystore.md#removekey)* -*Defined in [key_stores/merge_key_store.ts:34](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L34)* +*Defined in [key_stores/merge_key_store.ts:34](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L34)* **Parameters:** @@ -135,7 +135,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[setKey](_key_stores_keystore_.keystore.md#setkey)* -*Defined in [key_stores/merge_key_store.ts:20](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/merge_key_store.ts#L20)* +*Defined in [key_stores/merge_key_store.ts:20](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/merge_key_store.ts#L20)* **Parameters:** diff --git a/docs/classes/_key_stores_unencrypted_file_system_keystore_.unencryptedfilesystemkeystore.md b/docs/classes/_key_stores_unencrypted_file_system_keystore_.unencryptedfilesystemkeystore.md index 013d8ea5fd..8b581e0a9c 100644 --- a/docs/classes/_key_stores_unencrypted_file_system_keystore_.unencryptedfilesystemkeystore.md +++ b/docs/classes/_key_stores_unencrypted_file_system_keystore_.unencryptedfilesystemkeystore.md @@ -14,7 +14,7 @@ ⊕ **new UnencryptedFileSystemKeyStore**(keyDir: *`string`*): [UnencryptedFileSystemKeyStore](_key_stores_unencrypted_file_system_keystore_.unencryptedfilesystemkeystore.md) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:47](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L47)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L47)* **Parameters:** @@ -34,7 +34,7 @@ ___ **● keyDir**: *`string`* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:47](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L47)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L47)* ___ @@ -48,7 +48,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[clear](_key_stores_keystore_.keystore.md#clear)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:75](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L75)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:75](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L75)* **Returns:** `Promise`<`void`> @@ -61,7 +61,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getAccounts](_key_stores_keystore_.keystore.md#getaccounts)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:96](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L96)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:96](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L96)* **Parameters:** @@ -80,7 +80,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getKey](_key_stores_keystore_.keystore.md#getkey)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:60](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L60)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:60](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L60)* **Parameters:** @@ -98,7 +98,7 @@ ___ ▸ **getKeyFilePath**(networkId: *`string`*, accountId: *`string`*): `string` -*Defined in [key_stores/unencrypted_file_system_keystore.ts:83](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L83)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:83](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L83)* **Parameters:** @@ -118,7 +118,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[getNetworks](_key_stores_keystore_.keystore.md#getnetworks)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:87](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L87)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:87](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L87)* **Returns:** `Promise`<`string`[]> @@ -131,7 +131,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[removeKey](_key_stores_keystore_.keystore.md#removekey)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:69](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L69)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:69](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L69)* **Parameters:** @@ -151,7 +151,7 @@ ___ *Overrides [KeyStore](_key_stores_keystore_.keystore.md).[setKey](_key_stores_keystore_.keystore.md#setkey)* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:54](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L54)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:54](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L54)* **Parameters:** diff --git a/docs/classes/_near_.near.md b/docs/classes/_near_.near.md index 562a846181..208be33845 100644 --- a/docs/classes/_near_.near.md +++ b/docs/classes/_near_.near.md @@ -12,7 +12,7 @@ ⊕ **new Near**(config: *`any`*): [Near](_near_.near.md) -*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L14)* +*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L14)* **Parameters:** @@ -32,7 +32,7 @@ ___ **● accountCreator**: *[AccountCreator](_account_creator_.accountcreator.md)* -*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L14)* +*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L14)* ___ @@ -41,7 +41,7 @@ ___ **● config**: *`any`* -*Defined in [near.ts:12](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L12)* +*Defined in [near.ts:12](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L12)* ___ @@ -50,7 +50,7 @@ ___ **● connection**: *[Connection](_connection_.connection.md)* -*Defined in [near.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L13)* +*Defined in [near.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L13)* ___ @@ -62,7 +62,7 @@ ___ ▸ **account**(accountId: *`string`*): `Promise`<[Account](_account_.account.md)> -*Defined in [near.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L33)* +*Defined in [near.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L33)* **Parameters:** @@ -79,7 +79,7 @@ ___ ▸ **createAccount**(accountId: *`string`*, publicKey: *`string`*): `Promise`<[Account](_account_.account.md)> -*Defined in [near.ts:39](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L39)* +*Defined in [near.ts:39](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L39)* **Parameters:** @@ -97,7 +97,7 @@ ___ ▸ **deployContract**(contractId: *`string`*, wasmByteArray: *`Uint8Array`*): `Promise`<`string`> -*Defined in [near.ts:63](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L63)* +*Defined in [near.ts:63](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L63)* Backwards compatibility method. Use `contractAccount.deployContract` or `yourAccount.createAndDeployContract` instead. @@ -117,7 +117,7 @@ ___ ▸ **loadContract**(contractId: *`string`*, options: *`object`*): `Promise`<[Contract](_contract_.contract.md)> -*Defined in [near.ts:52](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L52)* +*Defined in [near.ts:52](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L52)* Backwards compatibility method. Use `new nearlib.Contract(yourAccount, contractId, { viewMethods, changeMethods })` instead. @@ -142,7 +142,7 @@ ___ ▸ **sendTokens**(amount: *`BN`*, originator: *`string`*, receiver: *`string`*): `Promise`<`string`> -*Defined in [near.ts:76](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L76)* +*Defined in [near.ts:76](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L76)* Backwards compatibility method. Use `yourAccount.sendMoney` instead. diff --git a/docs/classes/_providers_json_rpc_provider_.jsonrpcprovider.md b/docs/classes/_providers_json_rpc_provider_.jsonrpcprovider.md index 6ea722444d..54de4b8dd5 100644 --- a/docs/classes/_providers_json_rpc_provider_.jsonrpcprovider.md +++ b/docs/classes/_providers_json_rpc_provider_.jsonrpcprovider.md @@ -14,7 +14,7 @@ ⊕ **new JsonRpcProvider**(url?: *`string`*, network?: *[Network](../interfaces/_utils_network_.network.md)*): [JsonRpcProvider](_providers_json_rpc_provider_.jsonrpcprovider.md) -*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L13)* +*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L13)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● connection**: *[ConnectionInfo](../interfaces/_utils_web_.connectioninfo.md)* -*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L13)* +*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L13)* ___ @@ -49,7 +49,7 @@ ___ *Overrides [Provider](_providers_provider_.provider.md).[block](_providers_provider_.provider.md#block)* -*Defined in [providers/json-rpc-provider.ts:50](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L50)* +*Defined in [providers/json-rpc-provider.ts:50](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L50)* **Parameters:** @@ -68,7 +68,7 @@ ___ *Overrides [Provider](_providers_provider_.provider.md).[getNetwork](_providers_provider_.provider.md#getnetwork)* -*Defined in [providers/json-rpc-provider.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L22)* +*Defined in [providers/json-rpc-provider.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L22)* **Returns:** `Promise`<[Network](../interfaces/_utils_network_.network.md)> @@ -81,7 +81,7 @@ ___ *Overrides [Provider](_providers_provider_.provider.md).[query](_providers_provider_.provider.md#query)* -*Defined in [providers/json-rpc-provider.ts:42](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L42)* +*Defined in [providers/json-rpc-provider.ts:42](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L42)* **Parameters:** @@ -99,7 +99,7 @@ ___ ▸ **sendJsonRpc**(method: *`string`*, params: *`any`[]*): `Promise`<`any`> -*Defined in [providers/json-rpc-provider.ts:54](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L54)* +*Defined in [providers/json-rpc-provider.ts:54](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L54)* **Parameters:** @@ -115,17 +115,17 @@ ___ ## sendTransaction -▸ **sendTransaction**(signedTransaction: *`SignedTransaction`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **sendTransaction**(signedTransaction: *[SignedTransaction](_transaction_.signedtransaction.md)*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> *Overrides [Provider](_providers_provider_.provider.md).[sendTransaction](_providers_provider_.provider.md#sendtransaction)* -*Defined in [providers/json-rpc-provider.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L33)* +*Defined in [providers/json-rpc-provider.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L33)* **Parameters:** | Name | Type | | ------ | ------ | -| signedTransaction | `SignedTransaction` | +| signedTransaction | [SignedTransaction](_transaction_.signedtransaction.md) | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -138,7 +138,7 @@ ___ *Overrides [Provider](_providers_provider_.provider.md).[status](_providers_provider_.provider.md#status)* -*Defined in [providers/json-rpc-provider.ts:29](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L29)* +*Defined in [providers/json-rpc-provider.ts:29](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L29)* **Returns:** `Promise`<[NodeStatusResult](../interfaces/_providers_provider_.nodestatusresult.md)> @@ -151,7 +151,7 @@ ___ *Overrides [Provider](_providers_provider_.provider.md).[txStatus](_providers_provider_.provider.md#txstatus)* -*Defined in [providers/json-rpc-provider.ts:38](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L38)* +*Defined in [providers/json-rpc-provider.ts:38](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L38)* **Parameters:** diff --git a/docs/classes/_providers_provider_.provider.md b/docs/classes/_providers_provider_.provider.md index cb352c5d31..955f96cf9f 100644 --- a/docs/classes/_providers_provider_.provider.md +++ b/docs/classes/_providers_provider_.provider.md @@ -14,7 +14,7 @@ ▸ **block**(height: *`number`*): `Promise`<[BlockResult](../interfaces/_providers_provider_.blockresult.md)> -*Defined in [providers/provider.ts:75](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L75)* +*Defined in [providers/provider.ts:75](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L75)* **Parameters:** @@ -31,7 +31,7 @@ ___ ▸ **getNetwork**(): `Promise`<[Network](../interfaces/_utils_network_.network.md)> -*Defined in [providers/provider.ts:69](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L69)* +*Defined in [providers/provider.ts:69](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L69)* **Returns:** `Promise`<[Network](../interfaces/_utils_network_.network.md)> @@ -42,7 +42,7 @@ ___ ▸ **query**(path: *`string`*, data: *`string`*): `Promise`<`any`> -*Defined in [providers/provider.ts:74](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L74)* +*Defined in [providers/provider.ts:74](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L74)* **Parameters:** @@ -58,15 +58,15 @@ ___ ## `` sendTransaction -▸ **sendTransaction**(signedTransaction: *`SignedTransaction`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **sendTransaction**(signedTransaction: *[SignedTransaction](_transaction_.signedtransaction.md)*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [providers/provider.ts:72](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L72)* +*Defined in [providers/provider.ts:72](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L72)* **Parameters:** | Name | Type | | ------ | ------ | -| signedTransaction | `SignedTransaction` | +| signedTransaction | [SignedTransaction](_transaction_.signedtransaction.md) | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -77,7 +77,7 @@ ___ ▸ **status**(): `Promise`<[NodeStatusResult](../interfaces/_providers_provider_.nodestatusresult.md)> -*Defined in [providers/provider.ts:70](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L70)* +*Defined in [providers/provider.ts:70](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L70)* **Returns:** `Promise`<[NodeStatusResult](../interfaces/_providers_provider_.nodestatusresult.md)> @@ -88,7 +88,7 @@ ___ ▸ **txStatus**(txHash: *`Uint8Array`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [providers/provider.ts:73](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L73)* +*Defined in [providers/provider.ts:73](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L73)* **Parameters:** diff --git a/docs/classes/_signer_.inmemorysigner.md b/docs/classes/_signer_.inmemorysigner.md index d18e758a2c..48a5c31ba2 100644 --- a/docs/classes/_signer_.inmemorysigner.md +++ b/docs/classes/_signer_.inmemorysigner.md @@ -16,7 +16,7 @@ Signs using in memory key store. ⊕ **new InMemorySigner**(keyStore: *[KeyStore](_key_stores_keystore_.keystore.md)*): [InMemorySigner](_signer_.inmemorysigner.md) -*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L47)* +*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L47)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● keyStore**: *[KeyStore](_key_stores_keystore_.keystore.md)* -*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L47)* +*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L47)* ___ @@ -50,7 +50,7 @@ ___ *Overrides [Signer](_signer_.signer.md).[createKey](_signer_.signer.md#createkey)* -*Defined in [signer.ts:54](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L54)* +*Defined in [signer.ts:54](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L54)* **Parameters:** @@ -70,7 +70,7 @@ ___ *Overrides [Signer](_signer_.signer.md).[getPublicKey](_signer_.signer.md#getpublickey)* -*Defined in [signer.ts:60](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L60)* +*Defined in [signer.ts:60](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L60)* **Parameters:** @@ -90,7 +90,7 @@ ___ *Overrides [Signer](_signer_.signer.md).[signHash](_signer_.signer.md#signhash)* -*Defined in [signer.ts:65](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L65)* +*Defined in [signer.ts:65](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L65)* **Parameters:** @@ -111,7 +111,7 @@ ___ *Inherited from [Signer](_signer_.signer.md).[signMessage](_signer_.signer.md#signmessage)* -*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L38)* +*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L38)* Signs given message, by first hashing with sha256. diff --git a/docs/classes/_signer_.signer.md b/docs/classes/_signer_.signer.md index f7b4d3daef..357822700b 100644 --- a/docs/classes/_signer_.signer.md +++ b/docs/classes/_signer_.signer.md @@ -16,7 +16,7 @@ General signing interface, can be used for in memory signing, RPC singing, exter ▸ **createKey**(accountId: *`string`*, networkId?: *`string`*): `Promise`<`string`> -*Defined in [signer.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L15)* +*Defined in [signer.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L15)* Creates new key and returns public key. @@ -36,7 +36,7 @@ ___ ▸ **getPublicKey**(accountId?: *`string`*, networkId?: *`string`*): `Promise`<`string`> -*Defined in [signer.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L22)* +*Defined in [signer.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L22)* Returns public key for given account / network. @@ -56,7 +56,7 @@ ___ ▸ **signHash**(hash: *`Uint8Array`*, accountId?: *`string`*, networkId?: *`string`*): `Promise`<[Signature](../interfaces/_utils_key_pair_.signature.md)> -*Defined in [signer.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L30)* +*Defined in [signer.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L30)* Signs given hash. @@ -77,7 +77,7 @@ ___ ▸ **signMessage**(message: *`Uint8Array`*, accountId?: *`string`*, networkId?: *`string`*): `Promise`<[Signature](../interfaces/_utils_key_pair_.signature.md)> -*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/signer.ts#L38)* +*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/signer.ts#L38)* Signs given message, by first hashing with sha256. diff --git a/docs/classes/_transaction_.accesskey.md b/docs/classes/_transaction_.accesskey.md new file mode 100644 index 0000000000..28641f12c8 --- /dev/null +++ b/docs/classes/_transaction_.accesskey.md @@ -0,0 +1,51 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ AccessKey** + +# Constructors + + + +## constructor + +⊕ **new AccessKey**(properties: *`any`*): [AccessKey](_transaction_.accesskey.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [AccessKey](_transaction_.accesskey.md) + +___ + +# Properties + + + +## nonce + +**● nonce**: *`number`* + +*Defined in [transaction.ts:45](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L45)* + +___ + + +## permission + +**● permission**: *[AccessKeyPermission](_transaction_.accesskeypermission.md)* + +*Defined in [transaction.ts:46](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L46)* + +___ + diff --git a/docs/classes/_transaction_.accesskeypermission.md b/docs/classes/_transaction_.accesskeypermission.md new file mode 100644 index 0000000000..1589323102 --- /dev/null +++ b/docs/classes/_transaction_.accesskeypermission.md @@ -0,0 +1,62 @@ + + +# Hierarchy + + [Enum](_transaction_.enum.md) + +**↳ AccessKeyPermission** + +# Constructors + + + +## constructor + +⊕ **new AccessKeyPermission**(properties: *`any`*): [AccessKeyPermission](_transaction_.accesskeypermission.md) + +*Inherited from [Enum](_transaction_.enum.md).[constructor](_transaction_.enum.md#constructor)* + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [AccessKeyPermission](_transaction_.accesskeypermission.md) + +___ + +# Properties + + + +## enum + +**● enum**: *`string`* + +*Inherited from [Enum](_transaction_.enum.md).[enum](_transaction_.enum.md#enum)* + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +___ + + +## fullAccess + +**● fullAccess**: *[FullAccessPermission](_transaction_.fullaccesspermission.md)* + +*Defined in [transaction.ts:41](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L41)* + +___ + + +## functionCall + +**● functionCall**: *[FunctionCallPermission](_transaction_.functioncallpermission.md)* + +*Defined in [transaction.ts:40](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L40)* + +___ + diff --git a/docs/classes/_transaction_.action.md b/docs/classes/_transaction_.action.md new file mode 100644 index 0000000000..fee1c0a6a0 --- /dev/null +++ b/docs/classes/_transaction_.action.md @@ -0,0 +1,116 @@ + + +# Hierarchy + + [Enum](_transaction_.enum.md) + +**↳ Action** + +# Constructors + + + +## constructor + +⊕ **new Action**(properties: *`any`*): [Action](_transaction_.action.md) + +*Inherited from [Enum](_transaction_.enum.md).[constructor](_transaction_.enum.md#constructor)* + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Action](_transaction_.action.md) + +___ + +# Properties + + + +## addKey + +**● addKey**: *[AddKey](_transaction_.addkey.md)* + +*Defined in [transaction.ts:147](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L147)* + +___ + + +## createAccount + +**● createAccount**: *[CreateAccount](_transaction_.createaccount.md)* + +*Defined in [transaction.ts:142](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L142)* + +___ + + +## deleteAccount + +**● deleteAccount**: *[DeleteAccount](_transaction_.deleteaccount.md)* + +*Defined in [transaction.ts:149](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L149)* + +___ + + +## deleteKey + +**● deleteKey**: *[DeleteKey](_transaction_.deletekey.md)* + +*Defined in [transaction.ts:148](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L148)* + +___ + + +## deployContract + +**● deployContract**: *[DeployContract](_transaction_.deploycontract.md)* + +*Defined in [transaction.ts:143](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L143)* + +___ + + +## enum + +**● enum**: *`string`* + +*Inherited from [Enum](_transaction_.enum.md).[enum](_transaction_.enum.md#enum)* + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +___ + + +## functionCall + +**● functionCall**: *[FunctionCall](_transaction_.functioncall.md)* + +*Defined in [transaction.ts:144](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L144)* + +___ + + +## stake + +**● stake**: *[Stake](_transaction_.stake.md)* + +*Defined in [transaction.ts:146](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L146)* + +___ + + +## transfer + +**● transfer**: *[Transfer](_transaction_.transfer.md)* + +*Defined in [transaction.ts:145](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L145)* + +___ + diff --git a/docs/classes/_transaction_.addkey.md b/docs/classes/_transaction_.addkey.md new file mode 100644 index 0000000000..509d6d946d --- /dev/null +++ b/docs/classes/_transaction_.addkey.md @@ -0,0 +1,51 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ AddKey** + +# Constructors + + + +## constructor + +⊕ **new AddKey**(properties: *`any`*): [AddKey](_transaction_.addkey.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [AddKey](_transaction_.addkey.md) + +___ + +# Properties + + + +## accessKey + +**● accessKey**: *[AccessKey](_transaction_.accesskey.md)* + +*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L64)* + +___ + + +## publicKey + +**● publicKey**: *[PublicKey](_transaction_.publickey.md)* + +*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L64)* + +___ + diff --git a/docs/classes/_transaction_.assignable.md b/docs/classes/_transaction_.assignable.md new file mode 100644 index 0000000000..ca2aaa1cfe --- /dev/null +++ b/docs/classes/_transaction_.assignable.md @@ -0,0 +1,38 @@ + + +# Hierarchy + +**Assignable** + +↳ [FunctionCallPermission](_transaction_.functioncallpermission.md) + +↳ [FullAccessPermission](_transaction_.fullaccesspermission.md) + +↳ [AccessKey](_transaction_.accesskey.md) + +↳ [IAction](_transaction_.iaction.md) + +↳ [Transaction](_transaction_.transaction.md) + +↳ [SignedTransaction](_transaction_.signedtransaction.md) + +# Constructors + + + +## constructor + +⊕ **new Assignable**(properties: *`any`*): [Assignable](_transaction_.assignable.md) + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Assignable](_transaction_.assignable.md) + +___ + diff --git a/docs/classes/_transaction_.createaccount.md b/docs/classes/_transaction_.createaccount.md new file mode 100644 index 0000000000..5c17a3a12f --- /dev/null +++ b/docs/classes/_transaction_.createaccount.md @@ -0,0 +1,30 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ CreateAccount** + +# Constructors + + + +## constructor + +⊕ **new CreateAccount**(properties: *`any`*): [CreateAccount](_transaction_.createaccount.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [CreateAccount](_transaction_.createaccount.md) + +___ + diff --git a/docs/classes/_transaction_.deleteaccount.md b/docs/classes/_transaction_.deleteaccount.md new file mode 100644 index 0000000000..61a32a086d --- /dev/null +++ b/docs/classes/_transaction_.deleteaccount.md @@ -0,0 +1,42 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ DeleteAccount** + +# Constructors + + + +## constructor + +⊕ **new DeleteAccount**(properties: *`any`*): [DeleteAccount](_transaction_.deleteaccount.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [DeleteAccount](_transaction_.deleteaccount.md) + +___ + +# Properties + + + +## beneficiaryId + +**● beneficiaryId**: *`string`* + +*Defined in [transaction.ts:66](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L66)* + +___ + diff --git a/docs/classes/_transaction_.deletekey.md b/docs/classes/_transaction_.deletekey.md new file mode 100644 index 0000000000..e1644cc01f --- /dev/null +++ b/docs/classes/_transaction_.deletekey.md @@ -0,0 +1,42 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ DeleteKey** + +# Constructors + + + +## constructor + +⊕ **new DeleteKey**(properties: *`any`*): [DeleteKey](_transaction_.deletekey.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [DeleteKey](_transaction_.deletekey.md) + +___ + +# Properties + + + +## publicKey + +**● publicKey**: *[PublicKey](_transaction_.publickey.md)* + +*Defined in [transaction.ts:65](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L65)* + +___ + diff --git a/docs/classes/_transaction_.deploycontract.md b/docs/classes/_transaction_.deploycontract.md new file mode 100644 index 0000000000..0b29909b5f --- /dev/null +++ b/docs/classes/_transaction_.deploycontract.md @@ -0,0 +1,42 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ DeployContract** + +# Constructors + + + +## constructor + +⊕ **new DeployContract**(properties: *`any`*): [DeployContract](_transaction_.deploycontract.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [DeployContract](_transaction_.deploycontract.md) + +___ + +# Properties + + + +## code + +**● code**: *`Uint8Array`* + +*Defined in [transaction.ts:60](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L60)* + +___ + diff --git a/docs/classes/_transaction_.enum.md b/docs/classes/_transaction_.enum.md new file mode 100644 index 0000000000..6b9cbc6eee --- /dev/null +++ b/docs/classes/_transaction_.enum.md @@ -0,0 +1,42 @@ + + +# Hierarchy + +**Enum** + +↳ [AccessKeyPermission](_transaction_.accesskeypermission.md) + +↳ [Action](_transaction_.action.md) + +# Constructors + + + +## constructor + +⊕ **new Enum**(properties: *`any`*): [Enum](_transaction_.enum.md) + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Enum](_transaction_.enum.md) + +___ + +# Properties + + + +## enum + +**● enum**: *`string`* + +*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L10)* + +___ + diff --git a/docs/classes/_transaction_.fullaccesspermission.md b/docs/classes/_transaction_.fullaccesspermission.md new file mode 100644 index 0000000000..be90ffe963 --- /dev/null +++ b/docs/classes/_transaction_.fullaccesspermission.md @@ -0,0 +1,30 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ FullAccessPermission** + +# Constructors + + + +## constructor + +⊕ **new FullAccessPermission**(properties: *`any`*): [FullAccessPermission](_transaction_.fullaccesspermission.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [FullAccessPermission](_transaction_.fullaccesspermission.md) + +___ + diff --git a/docs/classes/_transaction_.functioncall.md b/docs/classes/_transaction_.functioncall.md new file mode 100644 index 0000000000..82798d18c5 --- /dev/null +++ b/docs/classes/_transaction_.functioncall.md @@ -0,0 +1,69 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ FunctionCall** + +# Constructors + + + +## constructor + +⊕ **new FunctionCall**(properties: *`any`*): [FunctionCall](_transaction_.functioncall.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [FunctionCall](_transaction_.functioncall.md) + +___ + +# Properties + + + +## args + +**● args**: *`Uint8Array`* + +*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L61)* + +___ + + +## deposit + +**● deposit**: *`BN`* + +*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L61)* + +___ + + +## gas + +**● gas**: *`BN`* + +*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L61)* + +___ + + +## methodName + +**● methodName**: *`string`* + +*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L61)* + +___ + diff --git a/docs/classes/_transaction_.functioncallpermission.md b/docs/classes/_transaction_.functioncallpermission.md new file mode 100644 index 0000000000..5d8fd6b1f0 --- /dev/null +++ b/docs/classes/_transaction_.functioncallpermission.md @@ -0,0 +1,60 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ FunctionCallPermission** + +# Constructors + + + +## constructor + +⊕ **new FunctionCallPermission**(properties: *`any`*): [FunctionCallPermission](_transaction_.functioncallpermission.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [FunctionCallPermission](_transaction_.functioncallpermission.md) + +___ + +# Properties + + + +## `` allowance + +**● allowance**: *`BN`* + +*Defined in [transaction.ts:32](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L32)* + +___ + + +## methodNames + +**● methodNames**: *`String`[]* + +*Defined in [transaction.ts:34](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L34)* + +___ + + +## receiverId + +**● receiverId**: *`string`* + +*Defined in [transaction.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L33)* + +___ + diff --git a/docs/classes/_transaction_.iaction.md b/docs/classes/_transaction_.iaction.md new file mode 100644 index 0000000000..9f2378ab56 --- /dev/null +++ b/docs/classes/_transaction_.iaction.md @@ -0,0 +1,46 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ IAction** + +↳ [CreateAccount](_transaction_.createaccount.md) + +↳ [DeployContract](_transaction_.deploycontract.md) + +↳ [FunctionCall](_transaction_.functioncall.md) + +↳ [Transfer](_transaction_.transfer.md) + +↳ [Stake](_transaction_.stake.md) + +↳ [AddKey](_transaction_.addkey.md) + +↳ [DeleteKey](_transaction_.deletekey.md) + +↳ [DeleteAccount](_transaction_.deleteaccount.md) + +# Constructors + + + +## constructor + +⊕ **new IAction**(properties: *`any`*): [IAction](_transaction_.iaction.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [IAction](_transaction_.iaction.md) + +___ + diff --git a/docs/classes/_transaction_.publickey.md b/docs/classes/_transaction_.publickey.md new file mode 100644 index 0000000000..fdbbc317e2 --- /dev/null +++ b/docs/classes/_transaction_.publickey.md @@ -0,0 +1,47 @@ + + +# Hierarchy + +**PublicKey** + +# Constructors + + + +## constructor + +⊕ **new PublicKey**(publicKey: *`string`*): [PublicKey](_transaction_.publickey.md) + +*Defined in [transaction.ts:106](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L106)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| publicKey | `string` | + +**Returns:** [PublicKey](_transaction_.publickey.md) + +___ + +# Properties + + + +## data + +**● data**: *`Uint8Array`* + +*Defined in [transaction.ts:106](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L106)* + +___ + + +## keyType + +**● keyType**: *[KeyType](../enums/_transaction_.keytype.md)* + +*Defined in [transaction.ts:105](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L105)* + +___ + diff --git a/docs/classes/_transaction_.signature.md b/docs/classes/_transaction_.signature.md new file mode 100644 index 0000000000..aa5b0fc30d --- /dev/null +++ b/docs/classes/_transaction_.signature.md @@ -0,0 +1,47 @@ + + +# Hierarchy + +**Signature** + +# Constructors + + + +## constructor + +⊕ **new Signature**(signature: *`Uint8Array`*): [Signature](_transaction_.signature.md) + +*Defined in [transaction.ts:116](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L116)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| signature | `Uint8Array` | + +**Returns:** [Signature](_transaction_.signature.md) + +___ + +# Properties + + + +## data + +**● data**: *`Uint8Array`* + +*Defined in [transaction.ts:116](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L116)* + +___ + + +## keyType + +**● keyType**: *[KeyType](../enums/_transaction_.keytype.md)* + +*Defined in [transaction.ts:115](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L115)* + +___ + diff --git a/docs/classes/_transaction_.signedtransaction.md b/docs/classes/_transaction_.signedtransaction.md new file mode 100644 index 0000000000..a0a2d9dc06 --- /dev/null +++ b/docs/classes/_transaction_.signedtransaction.md @@ -0,0 +1,65 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ SignedTransaction** + +# Constructors + + + +## constructor + +⊕ **new SignedTransaction**(properties: *`any`*): [SignedTransaction](_transaction_.signedtransaction.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [SignedTransaction](_transaction_.signedtransaction.md) + +___ + +# Properties + + + +## signature + +**● signature**: *[Signature](_transaction_.signature.md)* + +*Defined in [transaction.ts:134](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L134)* + +___ + + +## transaction + +**● transaction**: *[Transaction](_transaction_.transaction.md)* + +*Defined in [transaction.ts:133](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L133)* + +___ + +# Methods + + + +## encode + +▸ **encode**(): `Uint8Array` + +*Defined in [transaction.ts:136](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L136)* + +**Returns:** `Uint8Array` + +___ + diff --git a/docs/classes/_transaction_.stake.md b/docs/classes/_transaction_.stake.md new file mode 100644 index 0000000000..5db84eee72 --- /dev/null +++ b/docs/classes/_transaction_.stake.md @@ -0,0 +1,51 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ Stake** + +# Constructors + + + +## constructor + +⊕ **new Stake**(properties: *`any`*): [Stake](_transaction_.stake.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Stake](_transaction_.stake.md) + +___ + +# Properties + + + +## publicKey + +**● publicKey**: *[PublicKey](_transaction_.publickey.md)* + +*Defined in [transaction.ts:63](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L63)* + +___ + + +## stake + +**● stake**: *`BN`* + +*Defined in [transaction.ts:63](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L63)* + +___ + diff --git a/docs/classes/_transaction_.transaction.md b/docs/classes/_transaction_.transaction.md new file mode 100644 index 0000000000..99a966a317 --- /dev/null +++ b/docs/classes/_transaction_.transaction.md @@ -0,0 +1,78 @@ + + +# Hierarchy + + [Assignable](_transaction_.assignable.md) + +**↳ Transaction** + +# Constructors + + + +## constructor + +⊕ **new Transaction**(properties: *`any`*): [Transaction](_transaction_.transaction.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Transaction](_transaction_.transaction.md) + +___ + +# Properties + + + +## actions + +**● actions**: *[Action](_transaction_.action.md)[]* + +*Defined in [transaction.ts:129](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L129)* + +___ + + +## nonce + +**● nonce**: *`number`* + +*Defined in [transaction.ts:127](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L127)* + +___ + + +## publicKey + +**● publicKey**: *[PublicKey](_transaction_.publickey.md)* + +*Defined in [transaction.ts:126](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L126)* + +___ + + +## receiverId + +**● receiverId**: *`string`* + +*Defined in [transaction.ts:128](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L128)* + +___ + + +## signerId + +**● signerId**: *`string`* + +*Defined in [transaction.ts:125](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L125)* + +___ + diff --git a/docs/classes/_transaction_.transfer.md b/docs/classes/_transaction_.transfer.md new file mode 100644 index 0000000000..fb1c786864 --- /dev/null +++ b/docs/classes/_transaction_.transfer.md @@ -0,0 +1,42 @@ + + +# Hierarchy + +↳ [IAction](_transaction_.iaction.md) + +**↳ Transfer** + +# Constructors + + + +## constructor + +⊕ **new Transfer**(properties: *`any`*): [Transfer](_transaction_.transfer.md) + +*Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* + +*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L23)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| properties | `any` | + +**Returns:** [Transfer](_transaction_.transfer.md) + +___ + +# Properties + + + +## deposit + +**● deposit**: *`BN`* + +*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L62)* + +___ + diff --git a/docs/classes/_utils_key_pair_.keypair.md b/docs/classes/_utils_key_pair_.keypair.md index 970175001c..78e41dba7d 100644 --- a/docs/classes/_utils_key_pair_.keypair.md +++ b/docs/classes/_utils_key_pair_.keypair.md @@ -14,7 +14,7 @@ ▸ **getPublicKey**(): `string` -*Defined in [utils/key_pair.ts:17](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L17)* +*Defined in [utils/key_pair.ts:17](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L17)* **Returns:** `string` @@ -25,7 +25,7 @@ ___ ▸ **sign**(message: *`Uint8Array`*): [Signature](../interfaces/_utils_key_pair_.signature.md) -*Defined in [utils/key_pair.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L14)* +*Defined in [utils/key_pair.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L14)* **Parameters:** @@ -42,7 +42,7 @@ ___ ▸ **toString**(): `string` -*Defined in [utils/key_pair.ts:16](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L16)* +*Defined in [utils/key_pair.ts:16](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L16)* **Returns:** `string` @@ -53,7 +53,7 @@ ___ ▸ **verify**(message: *`Uint8Array`*, signature: *`Uint8Array`*): `boolean` -*Defined in [utils/key_pair.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L15)* +*Defined in [utils/key_pair.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L15)* **Parameters:** @@ -71,7 +71,7 @@ ___ ▸ **fromRandom**(curve: *`string`*): [KeyPair](_utils_key_pair_.keypair.md) -*Defined in [utils/key_pair.ts:19](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L19)* +*Defined in [utils/key_pair.ts:19](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L19)* **Parameters:** @@ -88,7 +88,7 @@ ___ ▸ **fromString**(encodedKey: *`string`*): [KeyPair](_utils_key_pair_.keypair.md) -*Defined in [utils/key_pair.ts:26](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L26)* +*Defined in [utils/key_pair.ts:26](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L26)* **Parameters:** diff --git a/docs/classes/_utils_key_pair_.keypaired25519.md b/docs/classes/_utils_key_pair_.keypaired25519.md index 76d9b8e3c5..d055ab78df 100644 --- a/docs/classes/_utils_key_pair_.keypaired25519.md +++ b/docs/classes/_utils_key_pair_.keypaired25519.md @@ -16,7 +16,7 @@ This class provides key pair functionality for Ed25519 curve: generating key pai ⊕ **new KeyPairEd25519**(secretKey: *`string`*): [KeyPairEd25519](_utils_key_pair_.keypaired25519.md) -*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L44)* +*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L44)* Construct an instance of key pair given a secret key. It's generally assumed that these are encoded in base58. @@ -38,7 +38,7 @@ ___ **● publicKey**: *`string`* -*Defined in [utils/key_pair.ts:43](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L43)* +*Defined in [utils/key_pair.ts:43](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L43)* ___ @@ -47,7 +47,7 @@ ___ **● secretKey**: *`string`* -*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L44)* +*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L44)* ___ @@ -61,7 +61,7 @@ ___ *Overrides [KeyPair](_utils_key_pair_.keypair.md).[getPublicKey](_utils_key_pair_.keypair.md#getpublickey)* -*Defined in [utils/key_pair.ts:86](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L86)* +*Defined in [utils/key_pair.ts:86](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L86)* **Returns:** `string` @@ -74,7 +74,7 @@ ___ *Overrides [KeyPair](_utils_key_pair_.keypair.md).[sign](_utils_key_pair_.keypair.md#sign)* -*Defined in [utils/key_pair.ts:73](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L73)* +*Defined in [utils/key_pair.ts:73](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L73)* **Parameters:** @@ -93,7 +93,7 @@ ___ *Overrides [KeyPair](_utils_key_pair_.keypair.md).[toString](_utils_key_pair_.keypair.md#tostring)* -*Defined in [utils/key_pair.ts:82](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L82)* +*Defined in [utils/key_pair.ts:82](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L82)* **Returns:** `string` @@ -106,7 +106,7 @@ ___ *Overrides [KeyPair](_utils_key_pair_.keypair.md).[verify](_utils_key_pair_.keypair.md#verify)* -*Defined in [utils/key_pair.ts:78](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L78)* +*Defined in [utils/key_pair.ts:78](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L78)* **Parameters:** @@ -126,7 +126,7 @@ ___ *Overrides [KeyPair](_utils_key_pair_.keypair.md).[fromRandom](_utils_key_pair_.keypair.md#fromrandom)* -*Defined in [utils/key_pair.ts:68](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L68)* +*Defined in [utils/key_pair.ts:68](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L68)* Generate a new random keypair. @@ -145,7 +145,7 @@ ___ *Inherited from [KeyPair](_utils_key_pair_.keypair.md).[fromString](_utils_key_pair_.keypair.md#fromstring)* -*Defined in [utils/key_pair.ts:26](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L26)* +*Defined in [utils/key_pair.ts:26](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L26)* **Parameters:** diff --git a/docs/classes/_utils_serialize_.binaryreader.md b/docs/classes/_utils_serialize_.binaryreader.md new file mode 100644 index 0000000000..81992c14ac --- /dev/null +++ b/docs/classes/_utils_serialize_.binaryreader.md @@ -0,0 +1,156 @@ + + +# Hierarchy + +**BinaryReader** + +# Constructors + + + +## constructor + +⊕ **new BinaryReader**(buf: *`Buffer`*): [BinaryReader](_utils_serialize_.binaryreader.md) + +*Defined in [utils/serialize.ts:89](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L89)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| buf | `Buffer` | + +**Returns:** [BinaryReader](_utils_serialize_.binaryreader.md) + +___ + +# Properties + + + +## buf + +**● buf**: *`Buffer`* + +*Defined in [utils/serialize.ts:88](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L88)* + +___ + + +## offset + +**● offset**: *`number`* + +*Defined in [utils/serialize.ts:89](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L89)* + +___ + +# Methods + + + +## read_array + +▸ **read_array**(fn: *`any`*): `any`[] + +*Defined in [utils/serialize.ts:134](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L134)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| fn | `any` | + +**Returns:** `any`[] + +___ + + +## `` read_buffer + +▸ **read_buffer**(len: *`number`*): `Buffer` + +*Defined in [utils/serialize.ts:119](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L119)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| len | `number` | + +**Returns:** `Buffer` + +___ + + +## read_fixed_array + +▸ **read_fixed_array**(len: *`number`*): `Uint8Array` + +*Defined in [utils/serialize.ts:130](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L130)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| len | `number` | + +**Returns:** `Uint8Array` + +___ + + +## read_string + +▸ **read_string**(): `string` + +*Defined in [utils/serialize.ts:125](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L125)* + +**Returns:** `string` + +___ + + +## read_u128 + +▸ **read_u128**(): `BN` + +*Defined in [utils/serialize.ts:114](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L114)* + +**Returns:** `BN` + +___ + + +## read_u32 + +▸ **read_u32**(): `number` + +*Defined in [utils/serialize.ts:102](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L102)* + +**Returns:** `number` + +___ + + +## read_u64 + +▸ **read_u64**(): `BN` + +*Defined in [utils/serialize.ts:108](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L108)* + +**Returns:** `BN` + +___ + + +## read_u8 + +▸ **read_u8**(): `number` + +*Defined in [utils/serialize.ts:96](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L96)* + +**Returns:** `number` + +___ + diff --git a/docs/classes/_utils_serialize_.binarywriter.md b/docs/classes/_utils_serialize_.binarywriter.md new file mode 100644 index 0000000000..b36ce73dbc --- /dev/null +++ b/docs/classes/_utils_serialize_.binarywriter.md @@ -0,0 +1,203 @@ + + +# Hierarchy + +**BinaryWriter** + +# Constructors + + + +## constructor + +⊕ **new BinaryWriter**(): [BinaryWriter](_utils_serialize_.binarywriter.md) + +*Defined in [utils/serialize.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L22)* + +**Returns:** [BinaryWriter](_utils_serialize_.binarywriter.md) + +___ + +# Properties + + + +## buf + +**● buf**: *`Buffer`* + +*Defined in [utils/serialize.ts:21](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L21)* + +___ + + +## length + +**● length**: *`number`* + +*Defined in [utils/serialize.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L22)* + +___ + +# Methods + + + +## maybe_resize + +▸ **maybe_resize**(): `void` + +*Defined in [utils/serialize.ts:29](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L29)* + +**Returns:** `void` + +___ + + +## toArray + +▸ **toArray**(): `Uint8Array` + +*Defined in [utils/serialize.ts:82](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L82)* + +**Returns:** `Uint8Array` + +___ + + +## write_array + +▸ **write_array**(array: *`any`[]*, fn: *`any`*): `void` + +*Defined in [utils/serialize.ts:73](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L73)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| array | `any`[] | +| fn | `any` | + +**Returns:** `void` + +___ + + +## `` write_buffer + +▸ **write_buffer**(buffer: *`Buffer`*): `void` + +*Defined in [utils/serialize.ts:57](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L57)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| buffer | `Buffer` | + +**Returns:** `void` + +___ + + +## write_fixed_array + +▸ **write_fixed_array**(array: *`Uint8Array`*): `void` + +*Defined in [utils/serialize.ts:69](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L69)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| array | `Uint8Array` | + +**Returns:** `void` + +___ + + +## write_string + +▸ **write_string**(str: *`string`*): `void` + +*Defined in [utils/serialize.ts:62](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L62)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| str | `string` | + +**Returns:** `void` + +___ + + +## write_u128 + +▸ **write_u128**(value: *`BN`*): `void` + +*Defined in [utils/serialize.ts:52](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L52)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| value | `BN` | + +**Returns:** `void` + +___ + + +## write_u32 + +▸ **write_u32**(value: *`number`*): `void` + +*Defined in [utils/serialize.ts:41](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L41)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| value | `number` | + +**Returns:** `void` + +___ + + +## write_u64 + +▸ **write_u64**(value: *`BN`*): `void` + +*Defined in [utils/serialize.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L47)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| value | `BN` | + +**Returns:** `void` + +___ + + +## write_u8 + +▸ **write_u8**(value: *`number`*): `void` + +*Defined in [utils/serialize.ts:35](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L35)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| value | `number` | + +**Returns:** `void` + +___ + diff --git a/docs/classes/_wallet_account_.walletaccount.md b/docs/classes/_wallet_account_.walletaccount.md index 4b59a1fce3..9ddda39f0a 100644 --- a/docs/classes/_wallet_account_.walletaccount.md +++ b/docs/classes/_wallet_account_.walletaccount.md @@ -12,7 +12,7 @@ ⊕ **new WalletAccount**(near: *[Near](_near_.near.md)*, appKeyPrefix: *`string` \| `null`*): [WalletAccount](_wallet_account_.walletaccount.md) -*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L18)* +*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L18)* **Parameters:** @@ -33,7 +33,7 @@ ___ **● _authData**: *`any`* -*Defined in [wallet-account.ts:17](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L17)* +*Defined in [wallet-account.ts:17](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L17)* ___ @@ -42,7 +42,7 @@ ___ **● _authDataKey**: *`string`* -*Defined in [wallet-account.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L15)* +*Defined in [wallet-account.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L15)* ___ @@ -51,7 +51,7 @@ ___ **● _keyStore**: *[KeyStore](_key_stores_keystore_.keystore.md)* -*Defined in [wallet-account.ts:16](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L16)* +*Defined in [wallet-account.ts:16](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L16)* ___ @@ -60,7 +60,7 @@ ___ **● _networkId**: *`string`* -*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L18)* +*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L18)* ___ @@ -69,7 +69,7 @@ ___ **● _walletBaseUrl**: *`string`* -*Defined in [wallet-account.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L14)* +*Defined in [wallet-account.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L14)* ___ @@ -81,7 +81,7 @@ ___ ▸ **_completeSignInWithAccessKey**(): `Promise`<`void`> -*Defined in [wallet-account.ts:84](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L84)* +*Defined in [wallet-account.ts:84](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L84)* Complete sign in for a given account id and public key. To be invoked by the app when getting a callback from the wallet. @@ -94,7 +94,7 @@ ___ ▸ **_moveKeyFromTempToPermanent**(accountId: *`string`*, publicKey: *`string`*): `Promise`<`void`> -*Defined in [wallet-account.ts:97](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L97)* +*Defined in [wallet-account.ts:97](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L97)* **Parameters:** @@ -112,7 +112,7 @@ ___ ▸ **getAccountId**(): `any` -*Defined in [wallet-account.ts:46](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L46)* +*Defined in [wallet-account.ts:46](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L46)* Returns authorized Account ID. @@ -127,7 +127,7 @@ ___ ▸ **isSignedIn**(): `boolean` -*Defined in [wallet-account.ts:37](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L37)* +*Defined in [wallet-account.ts:37](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L37)* Returns true, if this WalletAccount is authorized with the wallet. @@ -142,7 +142,7 @@ ___ ▸ **requestSignIn**(contractId: *`string`*, title: *`string`*, successUrl: *`string`*, failureUrl: *`string`*): `Promise`<`void`> -*Defined in [wallet-account.ts:63](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L63)* +*Defined in [wallet-account.ts:63](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L63)* Redirects current page to the wallet authentication page. @@ -166,7 +166,7 @@ ___ ▸ **signOut**(): `void` -*Defined in [wallet-account.ts:108](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L108)* +*Defined in [wallet-account.ts:108](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L108)* Sign out from the current account diff --git a/docs/enums/_providers_provider_.finaltransactionstatus.md b/docs/enums/_providers_provider_.finaltransactionstatus.md index 813c0b5535..f4b285c32f 100644 --- a/docs/enums/_providers_provider_.finaltransactionstatus.md +++ b/docs/enums/_providers_provider_.finaltransactionstatus.md @@ -19,7 +19,7 @@ **Completed**: = "Completed" -*Defined in [providers/provider.ts:25](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L25)* +*Defined in [providers/provider.ts:25](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L25)* ___ @@ -28,7 +28,7 @@ ___ **Failed**: = "Failed" -*Defined in [providers/provider.ts:24](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L24)* +*Defined in [providers/provider.ts:24](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L24)* ___ @@ -37,7 +37,7 @@ ___ **Started**: = "Started" -*Defined in [providers/provider.ts:23](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L23)* +*Defined in [providers/provider.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L23)* ___ @@ -46,7 +46,7 @@ ___ **Unknown**: = "Unknown" -*Defined in [providers/provider.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L22)* +*Defined in [providers/provider.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L22)* ___ diff --git a/docs/enums/_transaction_.keytype.md b/docs/enums/_transaction_.keytype.md new file mode 100644 index 0000000000..3744494ceb --- /dev/null +++ b/docs/enums/_transaction_.keytype.md @@ -0,0 +1,22 @@ + + +# Index + +### Enumeration members + +* [ED25519](_transaction_.keytype.md#ed25519) + +--- + +# Enumeration members + + + +## ED25519 + +**ED25519**: = 0 + +*Defined in [transaction.ts:101](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L101)* + +___ + diff --git a/docs/interfaces/_account_.accountstate.md b/docs/interfaces/_account_.accountstate.md index dfa6d8a1da..1d3118c2b6 100644 --- a/docs/interfaces/_account_.accountstate.md +++ b/docs/interfaces/_account_.accountstate.md @@ -12,7 +12,7 @@ **● account_id**: *`string`* -*Defined in [account.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L30)* +*Defined in [account.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L30)* ___ @@ -21,7 +21,7 @@ ___ **● amount**: *`string`* -*Defined in [account.ts:32](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L32)* +*Defined in [account.ts:31](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L31)* ___ @@ -30,34 +30,16 @@ ___ **● code_hash**: *`string`* -*Defined in [account.ts:35](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L35)* +*Defined in [account.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L33)* ___ - + -## nonce +## staked -**● nonce**: *`number`* +**● staked**: *`string`* -*Defined in [account.ts:31](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L31)* - -___ - - -## public_keys - -**● public_keys**: *`Uint8Array`[]* - -*Defined in [account.ts:34](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L34)* - -___ - - -## stake - -**● stake**: *`string`* - -*Defined in [account.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L33)* +*Defined in [account.ts:32](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L32)* ___ diff --git a/docs/interfaces/_key_stores_unencrypted_file_system_keystore_.accountinfo.md b/docs/interfaces/_key_stores_unencrypted_file_system_keystore_.accountinfo.md index a01d0901ea..d4f0144644 100644 --- a/docs/interfaces/_key_stores_unencrypted_file_system_keystore_.accountinfo.md +++ b/docs/interfaces/_key_stores_unencrypted_file_system_keystore_.accountinfo.md @@ -14,7 +14,7 @@ Format of the account stored on disk. **● account_id**: *`string`* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:29](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L29)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:29](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L29)* ___ @@ -23,7 +23,7 @@ ___ **● private_key**: *`string`* -*Defined in [key_stores/unencrypted_file_system_keystore.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L30)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L30)* ___ diff --git a/docs/interfaces/_providers_provider_.blockheader.md b/docs/interfaces/_providers_provider_.blockheader.md index 34ffa988e5..0ffc750bfb 100644 --- a/docs/interfaces/_providers_provider_.blockheader.md +++ b/docs/interfaces/_providers_provider_.blockheader.md @@ -12,7 +12,7 @@ **● approval_mask**: *`string`* -*Defined in [providers/provider.ts:45](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L45)* +*Defined in [providers/provider.ts:45](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L45)* ___ @@ -21,7 +21,7 @@ ___ **● approval_sigs**: *`string`* -*Defined in [providers/provider.ts:46](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L46)* +*Defined in [providers/provider.ts:46](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L46)* ___ @@ -30,7 +30,7 @@ ___ **● hash**: *`string`* -*Defined in [providers/provider.ts:47](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L47)* +*Defined in [providers/provider.ts:47](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L47)* ___ @@ -39,7 +39,7 @@ ___ **● height**: *`number`* -*Defined in [providers/provider.ts:48](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L48)* +*Defined in [providers/provider.ts:48](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L48)* ___ @@ -48,7 +48,7 @@ ___ **● prev_hash**: *`string`* -*Defined in [providers/provider.ts:49](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L49)* +*Defined in [providers/provider.ts:49](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L49)* ___ @@ -57,7 +57,7 @@ ___ **● prev_state_root**: *`string`* -*Defined in [providers/provider.ts:50](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L50)* +*Defined in [providers/provider.ts:50](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L50)* ___ @@ -66,7 +66,7 @@ ___ **● timestamp**: *`number`* -*Defined in [providers/provider.ts:51](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L51)* +*Defined in [providers/provider.ts:51](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L51)* ___ @@ -75,7 +75,7 @@ ___ **● total_weight**: *[TotalWeight](_providers_provider_.totalweight.md)* -*Defined in [providers/provider.ts:52](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L52)* +*Defined in [providers/provider.ts:52](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L52)* ___ @@ -84,7 +84,7 @@ ___ **● tx_root**: *`string`* -*Defined in [providers/provider.ts:53](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L53)* +*Defined in [providers/provider.ts:53](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L53)* ___ diff --git a/docs/interfaces/_providers_provider_.blockresult.md b/docs/interfaces/_providers_provider_.blockresult.md index 075e05bacc..d5723355d8 100644 --- a/docs/interfaces/_providers_provider_.blockresult.md +++ b/docs/interfaces/_providers_provider_.blockresult.md @@ -12,7 +12,7 @@ **● header**: *[BlockHeader](_providers_provider_.blockheader.md)* -*Defined in [providers/provider.ts:64](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L64)* +*Defined in [providers/provider.ts:64](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L64)* ___ @@ -21,7 +21,7 @@ ___ **● transactions**: *[Transaction](_providers_provider_.transaction.md)[]* -*Defined in [providers/provider.ts:65](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L65)* +*Defined in [providers/provider.ts:65](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L65)* ___ diff --git a/docs/interfaces/_providers_provider_.finaltransactionresult.md b/docs/interfaces/_providers_provider_.finaltransactionresult.md index f12202bf9d..7e76d7f419 100644 --- a/docs/interfaces/_providers_provider_.finaltransactionresult.md +++ b/docs/interfaces/_providers_provider_.finaltransactionresult.md @@ -12,7 +12,7 @@ **● logs**: *[TransactionLog](_providers_provider_.transactionlog.md)[]* -*Defined in [providers/provider.ts:37](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L37)* +*Defined in [providers/provider.ts:37](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L37)* ___ @@ -21,7 +21,7 @@ ___ **● status**: *[FinalTransactionStatus](../enums/_providers_provider_.finaltransactionstatus.md)* -*Defined in [providers/provider.ts:36](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L36)* +*Defined in [providers/provider.ts:36](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L36)* ___ diff --git a/docs/interfaces/_providers_provider_.nodestatusresult.md b/docs/interfaces/_providers_provider_.nodestatusresult.md index 55d1d1d979..256c19c4d9 100644 --- a/docs/interfaces/_providers_provider_.nodestatusresult.md +++ b/docs/interfaces/_providers_provider_.nodestatusresult.md @@ -12,7 +12,7 @@ **● chain_id**: *`string`* -*Defined in [providers/provider.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L15)* +*Defined in [providers/provider.ts:15](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L15)* ___ @@ -21,7 +21,7 @@ ___ **● rpc_addr**: *`string`* -*Defined in [providers/provider.ts:16](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L16)* +*Defined in [providers/provider.ts:16](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L16)* ___ @@ -30,7 +30,7 @@ ___ **● sync_info**: *[SyncInfo](_providers_provider_.syncinfo.md)* -*Defined in [providers/provider.ts:17](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L17)* +*Defined in [providers/provider.ts:17](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L17)* ___ @@ -39,7 +39,7 @@ ___ **● validators**: *`string`[]* -*Defined in [providers/provider.ts:18](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L18)* +*Defined in [providers/provider.ts:18](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L18)* ___ diff --git a/docs/interfaces/_providers_provider_.syncinfo.md b/docs/interfaces/_providers_provider_.syncinfo.md index 6363c514cd..183450964a 100644 --- a/docs/interfaces/_providers_provider_.syncinfo.md +++ b/docs/interfaces/_providers_provider_.syncinfo.md @@ -12,7 +12,7 @@ **● latest_block_hash**: *`string`* -*Defined in [providers/provider.ts:7](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L7)* +*Defined in [providers/provider.ts:7](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L7)* ___ @@ -21,7 +21,7 @@ ___ **● latest_block_height**: *`number`* -*Defined in [providers/provider.ts:8](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L8)* +*Defined in [providers/provider.ts:8](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L8)* ___ @@ -30,7 +30,7 @@ ___ **● latest_block_time**: *`string`* -*Defined in [providers/provider.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L9)* +*Defined in [providers/provider.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L9)* ___ @@ -39,7 +39,7 @@ ___ **● latest_state_root**: *`string`* -*Defined in [providers/provider.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L10)* +*Defined in [providers/provider.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L10)* ___ @@ -48,7 +48,7 @@ ___ **● syncing**: *`boolean`* -*Defined in [providers/provider.ts:11](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L11)* +*Defined in [providers/provider.ts:11](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L11)* ___ diff --git a/docs/interfaces/_providers_provider_.totalweight.md b/docs/interfaces/_providers_provider_.totalweight.md index 4a7a479190..8436a6ae43 100644 --- a/docs/interfaces/_providers_provider_.totalweight.md +++ b/docs/interfaces/_providers_provider_.totalweight.md @@ -12,7 +12,7 @@ **● num**: *`number`* -*Defined in [providers/provider.ts:41](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L41)* +*Defined in [providers/provider.ts:41](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L41)* ___ diff --git a/docs/interfaces/_providers_provider_.transaction.md b/docs/interfaces/_providers_provider_.transaction.md index ab67086bf7..23e9bc8dc4 100644 --- a/docs/interfaces/_providers_provider_.transaction.md +++ b/docs/interfaces/_providers_provider_.transaction.md @@ -12,7 +12,7 @@ **● body**: *`any`* -*Defined in [providers/provider.ts:60](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L60)* +*Defined in [providers/provider.ts:60](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L60)* ___ @@ -21,7 +21,7 @@ ___ **● hash**: *`string`* -*Defined in [providers/provider.ts:57](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L57)* +*Defined in [providers/provider.ts:57](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L57)* ___ @@ -30,7 +30,7 @@ ___ **● public_key**: *`string`* -*Defined in [providers/provider.ts:58](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L58)* +*Defined in [providers/provider.ts:58](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L58)* ___ @@ -39,7 +39,7 @@ ___ **● signature**: *`string`* -*Defined in [providers/provider.ts:59](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L59)* +*Defined in [providers/provider.ts:59](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L59)* ___ diff --git a/docs/interfaces/_providers_provider_.transactionlog.md b/docs/interfaces/_providers_provider_.transactionlog.md index 6fbf34e45c..08dc192821 100644 --- a/docs/interfaces/_providers_provider_.transactionlog.md +++ b/docs/interfaces/_providers_provider_.transactionlog.md @@ -12,7 +12,7 @@ **● hash**: *`string`* -*Defined in [providers/provider.ts:29](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L29)* +*Defined in [providers/provider.ts:29](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L29)* ___ @@ -21,7 +21,7 @@ ___ **● lines**: *`string`[]* -*Defined in [providers/provider.ts:30](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L30)* +*Defined in [providers/provider.ts:30](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L30)* ___ @@ -30,7 +30,7 @@ ___ **● receipts**: *`number`[][]* -*Defined in [providers/provider.ts:31](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L31)* +*Defined in [providers/provider.ts:31](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L31)* ___ @@ -39,7 +39,7 @@ ___ **● result**: *`Uint8Array`* -*Defined in [providers/provider.ts:32](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L32)* +*Defined in [providers/provider.ts:32](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L32)* ___ diff --git a/docs/interfaces/_utils_key_pair_.signature.md b/docs/interfaces/_utils_key_pair_.signature.md index d9bb488c57..671b1b10d6 100644 --- a/docs/interfaces/_utils_key_pair_.signature.md +++ b/docs/interfaces/_utils_key_pair_.signature.md @@ -12,7 +12,7 @@ **● publicKey**: *`string`* -*Defined in [utils/key_pair.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L10)* +*Defined in [utils/key_pair.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L10)* ___ @@ -21,7 +21,7 @@ ___ **● signature**: *`Uint8Array`* -*Defined in [utils/key_pair.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L9)* +*Defined in [utils/key_pair.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L9)* ___ diff --git a/docs/interfaces/_utils_network_.network.md b/docs/interfaces/_utils_network_.network.md index 88b3c4d275..8c09b96701 100644 --- a/docs/interfaces/_utils_network_.network.md +++ b/docs/interfaces/_utils_network_.network.md @@ -12,7 +12,7 @@ **● _defaultProvider**: *`function`* -*Defined in [utils/network.ts:6](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/network.ts#L6)* +*Defined in [utils/network.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/network.ts#L6)* #### Type declaration ▸(providers: *`any`*): `any` @@ -32,7 +32,7 @@ ___ **● chainId**: *`string`* -*Defined in [utils/network.ts:5](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/network.ts#L5)* +*Defined in [utils/network.ts:5](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/network.ts#L5)* ___ @@ -41,7 +41,7 @@ ___ **● name**: *`string`* -*Defined in [utils/network.ts:4](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/network.ts#L4)* +*Defined in [utils/network.ts:4](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/network.ts#L4)* ___ diff --git a/docs/interfaces/_utils_web_.connectioninfo.md b/docs/interfaces/_utils_web_.connectioninfo.md index 9bf7a3d013..6078e737e9 100644 --- a/docs/interfaces/_utils_web_.connectioninfo.md +++ b/docs/interfaces/_utils_web_.connectioninfo.md @@ -12,7 +12,7 @@ **● allowInsecure**: *`boolean`* -*Defined in [utils/web.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L9)* +*Defined in [utils/web.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L9)* ___ @@ -21,7 +21,7 @@ ___ **● headers**: *`object`* -*Defined in [utils/web.ts:11](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L11)* +*Defined in [utils/web.ts:11](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L11)* #### Type declaration @@ -34,7 +34,7 @@ ___ **● password**: *`string`* -*Defined in [utils/web.ts:8](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L8)* +*Defined in [utils/web.ts:8](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L8)* ___ @@ -43,7 +43,7 @@ ___ **● timeout**: *`number`* -*Defined in [utils/web.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L10)* +*Defined in [utils/web.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L10)* ___ @@ -52,7 +52,7 @@ ___ **● url**: *`string`* -*Defined in [utils/web.ts:6](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L6)* +*Defined in [utils/web.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L6)* ___ @@ -61,7 +61,7 @@ ___ **● user**: *`string`* -*Defined in [utils/web.ts:7](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L7)* +*Defined in [utils/web.ts:7](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L7)* ___ diff --git a/docs/modules/_account_.md b/docs/modules/_account_.md index bffbe4a293..364750576d 100644 --- a/docs/modules/_account_.md +++ b/docs/modules/_account_.md @@ -29,9 +29,9 @@ ## `` DEFAULT_FUNC_CALL_AMOUNT -**● DEFAULT_FUNC_CALL_AMOUNT**: *`BN`* = new BN(1000000000) +**● DEFAULT_FUNC_CALL_AMOUNT**: *`1000000`* = 1000000 -*Defined in [account.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L13)* +*Defined in [account.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L13)* ___ @@ -40,7 +40,7 @@ ___ **● TX_STATUS_RETRY_NUMBER**: *`10`* = 10 -*Defined in [account.ts:16](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L16)* +*Defined in [account.ts:16](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L16)* ___ @@ -49,7 +49,7 @@ ___ **● TX_STATUS_RETRY_WAIT**: *`500`* = 500 -*Defined in [account.ts:19](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L19)* +*Defined in [account.ts:19](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L19)* ___ @@ -58,7 +58,7 @@ ___ **● TX_STATUS_RETRY_WAIT_BACKOFF**: *`1.5`* = 1.5 -*Defined in [account.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L22)* +*Defined in [account.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L22)* ___ @@ -70,7 +70,7 @@ ___ ▸ **sleep**(millis: *`number`*): `Promise`<`any`> -*Defined in [account.ts:25](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/account.ts#L25)* +*Defined in [account.ts:25](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/account.ts#L25)* **Parameters:** diff --git a/docs/modules/_connection_.md b/docs/modules/_connection_.md index 81b457ec35..a646175d69 100644 --- a/docs/modules/_connection_.md +++ b/docs/modules/_connection_.md @@ -21,7 +21,7 @@ ▸ **getProvider**(config: *`any`*): [Provider](../classes/_providers_provider_.provider.md) -*Defined in [connection.ts:6](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L6)* +*Defined in [connection.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L6)* **Parameters:** @@ -38,7 +38,7 @@ ___ ▸ **getSigner**(networkId: *`string`*, config: *`any`*): [Signer](../classes/_signer_.signer.md) -*Defined in [connection.ts:13](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/connection.ts#L13)* +*Defined in [connection.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/connection.ts#L13)* **Parameters:** diff --git a/docs/modules/_key_stores_browser_local_storage_key_store_.md b/docs/modules/_key_stores_browser_local_storage_key_store_.md index 623139f03b..1ecd6723f7 100644 --- a/docs/modules/_key_stores_browser_local_storage_key_store_.md +++ b/docs/modules/_key_stores_browser_local_storage_key_store_.md @@ -20,7 +20,7 @@ **● LOCAL_STORAGE_KEY_PREFIX**: *"nearlib:keystore:"* = "nearlib:keystore:" -*Defined in [key_stores/browser_local_storage_key_store.ts:6](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/browser_local_storage_key_store.ts#L6)* +*Defined in [key_stores/browser_local_storage_key_store.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/browser_local_storage_key_store.ts#L6)* ___ diff --git a/docs/modules/_key_stores_unencrypted_file_system_keystore_.md b/docs/modules/_key_stores_unencrypted_file_system_keystore_.md index b2d71bf703..e0dd131052 100644 --- a/docs/modules/_key_stores_unencrypted_file_system_keystore_.md +++ b/docs/modules/_key_stores_unencrypted_file_system_keystore_.md @@ -35,7 +35,7 @@ **● exists**: *`Function`* = promisify(fs.exists) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:18](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L18)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:18](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L18)* ___ @@ -44,7 +44,7 @@ ___ **● mkdir**: *`Function`* = promisify(fs.mkdir) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:23](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L23)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:23](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L23)* ___ @@ -53,7 +53,7 @@ ___ **● readFile**: *`Function`* = promisify(fs.readFile) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:19](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L19)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:19](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L19)* ___ @@ -62,7 +62,7 @@ ___ **● readdir**: *`Function`* = promisify(fs.readdir) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:22](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L22)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:22](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L22)* ___ @@ -71,7 +71,7 @@ ___ **● unlink**: *`Function`* = promisify(fs.unlink) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:21](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L21)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:21](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L21)* ___ @@ -80,7 +80,7 @@ ___ **● writeFile**: *`Function`* = promisify(fs.writeFile) -*Defined in [key_stores/unencrypted_file_system_keystore.ts:20](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L20)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:20](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L20)* ___ @@ -92,7 +92,7 @@ ___ ▸ **ensureDir**(path: *`string`*): `Promise`<`void`> -*Defined in [key_stores/unencrypted_file_system_keystore.ts:38](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L38)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:38](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L38)* **Parameters:** @@ -109,7 +109,7 @@ ___ ▸ **loadJsonFile**(path: *`string`*): `Promise`<`any`> -*Defined in [key_stores/unencrypted_file_system_keystore.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L33)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:33](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L33)* **Parameters:** @@ -126,7 +126,7 @@ ___ ▸ **promisify**(fn: *`any`*): `Function` -*Defined in [key_stores/unencrypted_file_system_keystore.ts:9](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/key_stores/unencrypted_file_system_keystore.ts#L9)* +*Defined in [key_stores/unencrypted_file_system_keystore.ts:9](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/key_stores/unencrypted_file_system_keystore.ts#L9)* **Parameters:** diff --git a/docs/modules/_near_.md b/docs/modules/_near_.md index 669d6359f4..7612a0cd83 100644 --- a/docs/modules/_near_.md +++ b/docs/modules/_near_.md @@ -20,7 +20,7 @@ ▸ **connect**(config: *`any`*): `Promise`<[Near](../classes/_near_.near.md)> -*Defined in [near.ts:84](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/near.ts#L84)* +*Defined in [near.ts:84](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/near.ts#L84)* **Parameters:** diff --git a/docs/modules/_providers_json_rpc_provider_.md b/docs/modules/_providers_json_rpc_provider_.md index e4f95fc739..4b829d50e2 100644 --- a/docs/modules/_providers_json_rpc_provider_.md +++ b/docs/modules/_providers_json_rpc_provider_.md @@ -20,7 +20,7 @@ **● _nextId**: *`number`* = 123 -*Defined in [providers/json-rpc-provider.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/json-rpc-provider.ts#L10)* +*Defined in [providers/json-rpc-provider.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/json-rpc-provider.ts#L10)* ___ diff --git a/docs/modules/_providers_provider_.md b/docs/modules/_providers_provider_.md index aeb468b249..8d1789d056 100644 --- a/docs/modules/_providers_provider_.md +++ b/docs/modules/_providers_provider_.md @@ -35,7 +35,7 @@ ▸ **getTransactionLastResult**(txResult: *[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)*): `any` -*Defined in [providers/provider.ts:78](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/providers/provider.ts#L78)* +*Defined in [providers/provider.ts:78](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/providers/provider.ts#L78)* **Parameters:** diff --git a/docs/modules/_transaction_.md b/docs/modules/_transaction_.md index deef27b532..914a80a2a5 100644 --- a/docs/modules/_transaction_.md +++ b/docs/modules/_transaction_.md @@ -1,291 +1,767 @@ -# Type aliases +# Index + +### Enumerations + +* [KeyType](../enums/_transaction_.keytype.md) + +### Classes + +* [AccessKey](../classes/_transaction_.accesskey.md) +* [AccessKeyPermission](../classes/_transaction_.accesskeypermission.md) +* [Action](../classes/_transaction_.action.md) +* [AddKey](../classes/_transaction_.addkey.md) +* [Assignable](../classes/_transaction_.assignable.md) +* [CreateAccount](../classes/_transaction_.createaccount.md) +* [DeleteAccount](../classes/_transaction_.deleteaccount.md) +* [DeleteKey](../classes/_transaction_.deletekey.md) +* [DeployContract](../classes/_transaction_.deploycontract.md) +* [Enum](../classes/_transaction_.enum.md) +* [FullAccessPermission](../classes/_transaction_.fullaccesspermission.md) +* [FunctionCall](../classes/_transaction_.functioncall.md) +* [FunctionCallPermission](../classes/_transaction_.functioncallpermission.md) +* [IAction](../classes/_transaction_.iaction.md) +* [PublicKey](../classes/_transaction_.publickey.md) +* [Signature](../classes/_transaction_.signature.md) +* [SignedTransaction](../classes/_transaction_.signedtransaction.md) +* [Stake](../classes/_transaction_.stake.md) +* [Transaction](../classes/_transaction_.transaction.md) +* [Transfer](../classes/_transaction_.transfer.md) + +### Functions + +* [addKey](_transaction_.md#addkey-1) +* [createAccount](_transaction_.md#createaccount-1) +* [deleteAccount](_transaction_.md#deleteaccount-1) +* [deleteKey](_transaction_.md#deletekey-1) +* [deployContract](_transaction_.md#deploycontract-1) +* [fullAccessKey](_transaction_.md#fullaccesskey) +* [functionCall](_transaction_.md#functioncall-1) +* [functionCallAccessKey](_transaction_.md#functioncallaccesskey) +* [signTransaction](_transaction_.md#signtransaction) +* [stake](_transaction_.md#stake-1) +* [transfer](_transaction_.md#transfer-1) + +### Object literals + +* [SCHEMA](_transaction_.md#schema) + +--- - +# Functions -## AllTransactions + -**Ƭ AllTransactions**: *`SendMoneyTransaction` \| `CreateAccountTransaction` \| `DeployContractTransaction` \| `FunctionCallTransaction` \| `StakeTransaction` \| `SwapKeyTransaction` \| `AddKeyTransaction` \| `DeleteKeyTransaction`* +## addKey -*Defined in [transaction.ts:26](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L26)* +▸ **addKey**(publicKey: *`string`*, accessKey: *[AccessKey](../classes/_transaction_.accesskey.md)*): [Action](../classes/_transaction_.action.md) -___ +*Defined in [transaction.ts:88](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L88)* -# Variables +**Parameters:** - +| Name | Type | +| ------ | ------ | +| publicKey | `string` | +| accessKey | [AccessKey](../classes/_transaction_.accesskey.md) | -## `` TRANSACTION_FIELD_MAP +**Returns:** [Action](../classes/_transaction_.action.md) -**● TRANSACTION_FIELD_MAP**: *`Map`<`Function`, `string`>* = new Map([ - [CreateAccountTransaction, 'createAccount'], - [DeployContractTransaction, 'deployContract'], - [FunctionCallTransaction, 'functionCall'], - [SendMoneyTransaction, 'sendMoney'], - [StakeTransaction, 'stake'], - [SwapKeyTransaction, 'swapKey'], - [AddKeyTransaction, 'addKey'], - [DeleteKeyTransaction, 'deleteKey'], -]) +___ + -*Defined in [transaction.ts:15](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L15)* +## createAccount -___ +▸ **createAccount**(): [Action](../classes/_transaction_.action.md) -# Functions +*Defined in [transaction.ts:68](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L68)* - +**Returns:** [Action](../classes/_transaction_.action.md) -## addKey +___ + -▸ **addKey**(nonce: *`number`*, originator: *`string`*, newKey: *`string`*, accessKey: *`AccessKey`*): `AddKeyTransaction` +## deleteAccount -*Defined in [transaction.ts:70](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L70)* +▸ **deleteAccount**(beneficiaryId: *`string`*): [Action](../classes/_transaction_.action.md) + +*Defined in [transaction.ts:96](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L96)* **Parameters:** | Name | Type | | ------ | ------ | -| nonce | `number` | -| originator | `string` | -| newKey | `string` | -| accessKey | `AccessKey` | +| beneficiaryId | `string` | -**Returns:** `AddKeyTransaction` +**Returns:** [Action](../classes/_transaction_.action.md) ___ - + -## bigInt +## deleteKey -▸ **bigInt**(num: *`BN`*): `Uint128` +▸ **deleteKey**(publicKey: *`string`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:28](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L28)* +*Defined in [transaction.ts:92](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L92)* **Parameters:** | Name | Type | | ------ | ------ | -| num | `BN` | +| publicKey | `string` | -**Returns:** `Uint128` +**Returns:** [Action](../classes/_transaction_.action.md) ___ - + -## bignumHex2Dec +## deployContract -▸ **bignumHex2Dec**(num: *`string`*): `string` +▸ **deployContract**(code: *`Uint8Array`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:33](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L33)* +*Defined in [transaction.ts:72](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L72)* **Parameters:** | Name | Type | | ------ | ------ | -| num | `string` | +| code | `Uint8Array` | + +**Returns:** [Action](../classes/_transaction_.action.md) + +___ + + +## fullAccessKey + +▸ **fullAccessKey**(): [AccessKey](../classes/_transaction_.accesskey.md) -**Returns:** `string` +*Defined in [transaction.ts:49](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L49)* + +**Returns:** [AccessKey](../classes/_transaction_.accesskey.md) ___ - + -## createAccessKey +## functionCall -▸ **createAccessKey**(contractId?: *`string`*, methodName?: *`string`*, balanceOwner?: *`string`*, amount?: *`BN`*): `AccessKey` +▸ **functionCall**(methodName: *`string`*, args: *`Uint8Array`*, gas: *`number`*, deposit: *`BN`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L61)* +*Defined in [transaction.ts:76](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L76)* **Parameters:** | Name | Type | | ------ | ------ | -| `Optional` contractId | `string` | -| `Optional` methodName | `string` | -| `Optional` balanceOwner | `string` | -| `Optional` amount | `BN` | +| methodName | `string` | +| args | `Uint8Array` | +| gas | `number` | +| deposit | `BN` | -**Returns:** `AccessKey` +**Returns:** [Action](../classes/_transaction_.action.md) ___ - + -## createAccount +## functionCallAccessKey -▸ **createAccount**(nonce: *`number`*, originator: *`string`*, newAccountId: *`string`*, publicKey: *`string`*, amount: *`BN`*): `CreateAccountTransaction` +▸ **functionCallAccessKey**(receiverId: *`string`*, methodNames: *`String`[]*, allowance?: *`BN`*): [AccessKey](../classes/_transaction_.accesskey.md) -*Defined in [transaction.ts:37](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L37)* +*Defined in [transaction.ts:53](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L53)* **Parameters:** | Name | Type | | ------ | ------ | -| nonce | `number` | -| originator | `string` | -| newAccountId | `string` | -| publicKey | `string` | -| amount | `BN` | +| receiverId | `string` | +| methodNames | `String`[] | +| `Optional` allowance | `BN` | -**Returns:** `CreateAccountTransaction` +**Returns:** [AccessKey](../classes/_transaction_.accesskey.md) ___ - + -## deleteKey +## signTransaction -▸ **deleteKey**(nonce: *`number`*, originator: *`string`*, curKey: *`string`*): `DeleteKeyTransaction` +▸ **signTransaction**(receiverId: *`string`*, nonce: *`number`*, actions: *[Action](../classes/_transaction_.action.md)[]*, signer: *[Signer](../classes/_signer_.signer.md)*, accountId?: *`string`*, networkId?: *`string`*): `Promise`<[`Uint8Array`, [SignedTransaction](../classes/_transaction_.signedtransaction.md)]> -*Defined in [transaction.ts:74](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L74)* +*Defined in [transaction.ts:193](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L193)* **Parameters:** | Name | Type | | ------ | ------ | +| receiverId | `string` | | nonce | `number` | -| originator | `string` | -| curKey | `string` | +| actions | [Action](../classes/_transaction_.action.md)[] | +| signer | [Signer](../classes/_signer_.signer.md) | +| `Optional` accountId | `string` | +| `Optional` networkId | `string` | -**Returns:** `DeleteKeyTransaction` +**Returns:** `Promise`<[`Uint8Array`, [SignedTransaction](../classes/_transaction_.signedtransaction.md)]> ___ - + -## deployContract +## stake -▸ **deployContract**(nonce: *`number`*, contractId: *`string`*, wasmByteArray: *`Uint8Array`*): `DeployContractTransaction` +▸ **stake**(stake: *`BN`*, publicKey: *`string`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:41](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L41)* +*Defined in [transaction.ts:84](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L84)* **Parameters:** | Name | Type | | ------ | ------ | -| nonce | `number` | -| contractId | `string` | -| wasmByteArray | `Uint8Array` | +| stake | `BN` | +| publicKey | `string` | -**Returns:** `DeployContractTransaction` +**Returns:** [Action](../classes/_transaction_.action.md) ___ - + -## functionCall +## transfer -▸ **functionCall**(nonce: *`number`*, originator: *`string`*, contractId: *`string`*, methodName: *`string`*, args: *`Uint8Array`*, amount: *`BN`*): `FunctionCallTransaction` +▸ **transfer**(deposit: *`BN`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:45](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L45)* +*Defined in [transaction.ts:80](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L80)* **Parameters:** | Name | Type | | ------ | ------ | -| nonce | `number` | -| originator | `string` | -| contractId | `string` | -| methodName | `string` | -| args | `Uint8Array` | -| amount | `BN` | +| deposit | `BN` | -**Returns:** `FunctionCallTransaction` +**Returns:** [Action](../classes/_transaction_.action.md) ___ - -## sendMoney +# Object literals -▸ **sendMoney**(nonce: *`number`*, originator: *`string`*, receiver: *`string`*, amount: *`BN`*): `SendMoneyTransaction` + -*Defined in [transaction.ts:49](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L49)* +## `` SCHEMA -**Parameters:** +**SCHEMA**: *`object`* -| Name | Type | -| ------ | ------ | -| nonce | `number` | -| originator | `string` | -| receiver | `string` | -| amount | `BN` | +*Defined in [transaction.ts:152](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L152)* + + + +### AccessKey -**Returns:** `SendMoneyTransaction` +**AccessKey**: *`object`* + +*Defined in [transaction.ts:159](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L159)* + + + +### fields + +**● fields**: *(`string` \| [AccessKeyPermission](../classes/_transaction_.accesskeypermission.md))[][]* = [ + ['nonce', 'u64'], + ['permission', AccessKeyPermission], + ] + +*Defined in [transaction.ts:159](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L159)* ___ - + -## signTransaction +### kind -▸ **signTransaction**(signer: *[Signer](../classes/_signer_.signer.md)*, transaction: *`any`*, accountId?: *`string`*, networkId?: *`string`*): `Promise`<[`Uint8Array`, `SignedTransaction`]> +**● kind**: *`string`* = "struct" -*Defined in [transaction.ts:87](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L87)* +*Defined in [transaction.ts:159](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L159)* -**Parameters:** +___ -| Name | Type | -| ------ | ------ | -| signer | [Signer](../classes/_signer_.signer.md) | -| transaction | `any` | -| `Optional` accountId | `string` | -| `Optional` networkId | `string` | +___ + + +### AccessKeyPermission + +**AccessKeyPermission**: *`object`* + +*Defined in [transaction.ts:163](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L163)* + + + +### field -**Returns:** `Promise`<[`Uint8Array`, `SignedTransaction`]> +**● field**: *`string`* = "enum" + +*Defined in [transaction.ts:163](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L163)* ___ - + -## signedTransaction +### kind -▸ **signedTransaction**(transaction: *[AllTransactions](_transaction_.md#alltransactions)*, signature: *[Signature](../interfaces/_utils_key_pair_.signature.md)*): `SignedTransaction` +**● kind**: *`string`* = "enum" -*Defined in [transaction.ts:78](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L78)* +*Defined in [transaction.ts:163](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L163)* -**Parameters:** +___ + -| Name | Type | -| ------ | ------ | -| transaction | [AllTransactions](_transaction_.md#alltransactions) | -| signature | [Signature](../interfaces/_utils_key_pair_.signature.md) | +### values -**Returns:** `SignedTransaction` +**● values**: *(`string` \| [FullAccessPermission](../classes/_transaction_.fullaccesspermission.md))[][]* = [ + ['functionCall', FunctionCallPermission], + ['fullAccess', FullAccessPermission], + ] + +*Defined in [transaction.ts:163](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L163)* ___ - -## stake +___ + -▸ **stake**(nonce: *`number`*, originator: *`string`*, amount: *`BN`*, publicKey: *`string`*): `StakeTransaction` +### Action -*Defined in [transaction.ts:53](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L53)* +**Action**: *`object`* -**Parameters:** +*Defined in [transaction.ts:173](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L173)* -| Name | Type | -| ------ | ------ | -| nonce | `number` | -| originator | `string` | -| amount | `BN` | -| publicKey | `string` | + + +### field + +**● field**: *`string`* = "enum" -**Returns:** `StakeTransaction` +*Defined in [transaction.ts:173](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L173)* ___ - + -## swapKey +### kind -▸ **swapKey**(nonce: *`number`*, originator: *`string`*, curKey: *`string`*, newKey: *`string`*): `SwapKeyTransaction` +**● kind**: *`string`* = "enum" -*Defined in [transaction.ts:57](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/transaction.ts#L57)* +*Defined in [transaction.ts:173](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L173)* -**Parameters:** +___ + -| Name | Type | -| ------ | ------ | -| nonce | `number` | -| originator | `string` | -| curKey | `string` | -| newKey | `string` | +### values + +**● values**: *((`string` \| [CreateAccount](../classes/_transaction_.createaccount.md))[] \| (`string` \| [functionCall](_transaction_.md#functioncall-1))[] \| (`string` \| [stake](_transaction_.md#stake-1))[] \| (`string` \| [addKey](_transaction_.md#addkey-1))[])[]* = [ + ['createAccount', CreateAccount], + ['deployContract', DeployContract], + ['functionCall', functionCall], + ['transfer', transfer], + ['stake', stake], + ['addKey', addKey], + ['deleteKey', deleteKey], + ['deleteAccount', deleteAccount], + ] + +*Defined in [transaction.ts:173](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L173)* + +___ + +___ + + +### AddKey + +**AddKey**: *`object`* + +*Defined in [transaction.ts:188](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L188)* + + + +### fields + +**● fields**: *((`string` \| [PublicKey](../classes/_transaction_.publickey.md))[] \| (`string` \| [AccessKey](../classes/_transaction_.accesskey.md))[])[]* = [['publicKey', PublicKey], ['accessKey', AccessKey]] + +*Defined in [transaction.ts:188](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L188)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:188](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L188)* + +___ + +___ + + +### CreateAccount + +**CreateAccount**: *`object`* + +*Defined in [transaction.ts:183](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L183)* + + + +### fields + +**● fields**: *`undefined`[]* = [] + +*Defined in [transaction.ts:183](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L183)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:183](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L183)* + +___ + +___ + + +### DeleteAccount + +**DeleteAccount**: *`object`* + +*Defined in [transaction.ts:190](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L190)* + + + +### fields + +**● fields**: *`string`[][]* = [['beneficiaryId', 'string']] + +*Defined in [transaction.ts:190](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L190)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:190](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L190)* + +___ + +___ + + +### DeleteKey + +**DeleteKey**: *`object`* + +*Defined in [transaction.ts:189](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L189)* + + + +### fields + +**● fields**: *(`string` \| [PublicKey](../classes/_transaction_.publickey.md))[][]* = [['publicKey', PublicKey]] + +*Defined in [transaction.ts:189](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L189)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:189](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L189)* + +___ + +___ + -**Returns:** `SwapKeyTransaction` +### DeployContract + +**DeployContract**: *`object`* + +*Defined in [transaction.ts:184](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L184)* + + + +### fields + +**● fields**: *(`string` \| `string`[])[][]* = [['code', ['u8']]] + +*Defined in [transaction.ts:184](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L184)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:184](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L184)* + +___ + +___ + + +### FullAccessPermission + +**FullAccessPermission**: *`object`* + +*Defined in [transaction.ts:172](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L172)* + + + +### fields + +**● fields**: *`undefined`[]* = [] + +*Defined in [transaction.ts:172](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L172)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:172](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L172)* + +___ + +___ + + +### FunctionCall + +**FunctionCall**: *`object`* + +*Defined in [transaction.ts:185](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L185)* + + + +### fields + +**● fields**: *(`string` \| `string`[])[][]* = [['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128']] + +*Defined in [transaction.ts:185](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L185)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:185](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L185)* + +___ + +___ + + +### FunctionCallPermission + +**FunctionCallPermission**: *`object`* + +*Defined in [transaction.ts:167](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L167)* + + + +### fields + +**● fields**: *((`string` \| `object`)[] \| (`string` \| `string`[])[])[]* = [ + ['allowance', {kind: 'option', type: 'u128'}], + ['receiverId', 'string'], + ['methodNames', ['string']], + ] + +*Defined in [transaction.ts:167](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L167)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:167](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L167)* + +___ + +___ + + +### PublicKey + +**PublicKey**: *`object`* + +*Defined in [transaction.ts:157](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L157)* + + + +### fields + +**● fields**: *(`string` \| `number`[])[][]* = [['keyType', 'u8'], ['data', [32]]] + +*Defined in [transaction.ts:158](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L158)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:158](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L158)* + +___ + +___ + + +### Signature + +**Signature**: *`object`* + +*Defined in [transaction.ts:153](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L153)* + + + +### fields + +**● fields**: *(`string` \| `number`[])[][]* = [['keyType', 'u8'], ['data', [32]]] + +*Defined in [transaction.ts:153](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L153)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:153](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L153)* + +___ + +___ + + +### SignedTransaction + +**SignedTransaction**: *`object`* + +*Defined in [transaction.ts:154](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L154)* + + + +### fields + +**● fields**: *((`string` \| [Transaction](../classes/_transaction_.transaction.md))[] \| (`string` \| [Signature](../classes/_transaction_.signature.md))[])[]* = [['transaction', Transaction], ['signature', Signature]] + +*Defined in [transaction.ts:154](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L154)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:154](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L154)* + +___ + +___ + + +### Stake + +**Stake**: *`object`* + +*Defined in [transaction.ts:187](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L187)* + + + +### fields + +**● fields**: *(`string` \| [PublicKey](../classes/_transaction_.publickey.md))[][]* = [['stake', 'u128'], ['publicKey', PublicKey]] + +*Defined in [transaction.ts:187](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L187)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:187](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L187)* + +___ + +___ + + +### Transaction + +**Transaction**: *`object`* + +*Defined in [transaction.ts:155](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L155)* + + + +### fields + +**● fields**: *((`string` \| [PublicKey](../classes/_transaction_.publickey.md))[] \| (`string` \| [Action](../classes/_transaction_.action.md)[])[])[]* = [['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['actions', [Action]]] + +*Defined in [transaction.ts:156](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L156)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:156](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L156)* + +___ + +___ + + +### Transfer + +**Transfer**: *`object`* + +*Defined in [transaction.ts:186](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L186)* + + + +### fields + +**● fields**: *`string`[][]* = [['deposit', 'u128']] + +*Defined in [transaction.ts:186](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L186)* + +___ + + +### kind + +**● kind**: *`string`* = "struct" + +*Defined in [transaction.ts:186](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/transaction.ts#L186)* + +___ + +___ ___ diff --git a/docs/modules/_utils_key_pair_.md b/docs/modules/_utils_key_pair_.md index 2b4424d625..516d05851a 100644 --- a/docs/modules/_utils_key_pair_.md +++ b/docs/modules/_utils_key_pair_.md @@ -25,7 +25,7 @@ **Ƭ Arrayish**: *`string` \| `ArrayLike`<`number`>* -*Defined in [utils/key_pair.ts:6](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/key_pair.ts#L6)* +*Defined in [utils/key_pair.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/key_pair.ts#L6)* ___ diff --git a/docs/modules/_utils_serialize_.md b/docs/modules/_utils_serialize_.md index 157861f97d..964d57f65a 100644 --- a/docs/modules/_utils_serialize_.md +++ b/docs/modules/_utils_serialize_.md @@ -1,5 +1,41 @@ +# Index + +### Classes + +* [BinaryReader](../classes/_utils_serialize_.binaryreader.md) +* [BinaryWriter](../classes/_utils_serialize_.binarywriter.md) + +### Variables + +* [INITIAL_LENGTH](_utils_serialize_.md#initial_length) + +### Functions + +* [base_decode](_utils_serialize_.md#base_decode) +* [base_encode](_utils_serialize_.md#base_encode) +* [deserialize](_utils_serialize_.md#deserialize) +* [deserializeField](_utils_serialize_.md#deserializefield) +* [deserializeStruct](_utils_serialize_.md#deserializestruct) +* [serialize](_utils_serialize_.md#serialize) +* [serializeField](_utils_serialize_.md#serializefield) +* [serializeStruct](_utils_serialize_.md#serializestruct) + +--- + +# Variables + + + +## `` INITIAL_LENGTH + +**● INITIAL_LENGTH**: *`1024`* = 1024 + +*Defined in [utils/serialize.ts:17](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L17)* + +___ + # Functions @@ -8,7 +44,7 @@ ▸ **base_decode**(value: *`string`*): `Uint8Array` -*Defined in [utils/serialize.ts:12](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/serialize.ts#L12)* +*Defined in [utils/serialize.ts:13](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L13)* **Parameters:** @@ -25,7 +61,7 @@ ___ ▸ **base_encode**(value: *`Uint8Array` \| `string`*): `string` -*Defined in [utils/serialize.ts:5](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/serialize.ts#L5)* +*Defined in [utils/serialize.ts:6](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L6)* **Parameters:** @@ -36,4 +72,118 @@ ___ **Returns:** `string` ___ + + +## deserialize + +▸ **deserialize**(schema: *`any`*, classType: *`any`*, buffer: *`Buffer`*): `any` + +*Defined in [utils/serialize.ts:225](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L225)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| classType | `any` | +| buffer | `Buffer` | + +**Returns:** `any` + +___ + + +## deserializeField + +▸ **deserializeField**(schema: *`any`*, fieldType: *`any`*, reader: *`any`*): `any` + +*Defined in [utils/serialize.ts:203](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L203)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| fieldType | `any` | +| reader | `any` | + +**Returns:** `any` + +___ + + +## deserializeStruct + +▸ **deserializeStruct**(schema: *`any`*, classType: *`any`*, reader: *`any`*): `any` + +*Defined in [utils/serialize.ts:217](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L217)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| classType | `any` | +| reader | `any` | + +**Returns:** `any` + +___ + + +## serialize + +▸ **serialize**(schema: *`any`*, obj: *`any`*): `Uint8Array` + +*Defined in [utils/serialize.ts:197](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L197)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| obj | `any` | + +**Returns:** `Uint8Array` + +___ + + +## serializeField + +▸ **serializeField**(schema: *`any`*, value: *`any`*, fieldType: *`any`*, writer: *`any`*): `void` + +*Defined in [utils/serialize.ts:144](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L144)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| value | `any` | +| fieldType | `any` | +| writer | `any` | + +**Returns:** `void` + +___ + + +## serializeStruct + +▸ **serializeStruct**(schema: *`any`*, obj: *`any`*, writer: *`any`*): `void` + +*Defined in [utils/serialize.ts:171](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/serialize.ts#L171)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| schema | `any` | +| obj | `any` | +| writer | `any` | + +**Returns:** `void` + +___ diff --git a/docs/modules/_utils_web_.md b/docs/modules/_utils_web_.md index abeec92b1f..0b686dd59a 100644 --- a/docs/modules/_utils_web_.md +++ b/docs/modules/_utils_web_.md @@ -24,7 +24,7 @@ **● fetch**: *`any`* = (typeof window === 'undefined' || window.name === 'nodejs') ? require('node-fetch') : window.fetch -*Defined in [utils/web.ts:14](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L14)* +*Defined in [utils/web.ts:14](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L14)* ___ @@ -36,7 +36,7 @@ ___ ▸ **fetchJson**(connection: *`string` \| [ConnectionInfo](../interfaces/_utils_web_.connectioninfo.md)*, json?: *`string`*): `Promise`<`any`> -*Defined in [utils/web.ts:16](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/utils/web.ts#L16)* +*Defined in [utils/web.ts:16](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/utils/web.ts#L16)* **Parameters:** diff --git a/docs/modules/_wallet_account_.md b/docs/modules/_wallet_account_.md index 0585f9011b..7e4b118317 100644 --- a/docs/modules/_wallet_account_.md +++ b/docs/modules/_wallet_account_.md @@ -22,7 +22,7 @@ **● LOCAL_STORAGE_KEY_SUFFIX**: *"_wallet_auth_key"* = "_wallet_auth_key" -*Defined in [wallet-account.ts:10](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L10)* +*Defined in [wallet-account.ts:10](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L10)* ___ @@ -31,7 +31,7 @@ ___ **● LOGIN_WALLET_URL_SUFFIX**: *"/login/"* = "/login/" -*Defined in [wallet-account.ts:8](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L8)* +*Defined in [wallet-account.ts:8](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L8)* ___ @@ -40,7 +40,7 @@ ___ **● PENDING_ACCESS_KEY_PREFIX**: *"pending_key"* = "pending_key" -*Defined in [wallet-account.ts:11](https://github.com/nearprotocol/nearlib/blob/7e040fa/src.ts/wallet-account.ts#L11)* +*Defined in [wallet-account.ts:11](https://github.com/nearprotocol/nearlib/blob/01b260c/src.ts/wallet-account.ts#L11)* ___ diff --git a/lib/account.d.ts b/lib/account.d.ts index 9641504bc8..085b5c2083 100644 --- a/lib/account.d.ts +++ b/lib/account.d.ts @@ -11,7 +11,7 @@ export declare class Account { readonly connection: Connection; readonly accountId: string; private _state; - private _access_key; + private _accessKey; private _ready; protected readonly ready: Promise; constructor(connection: Connection, accountId: string); diff --git a/lib/account.js b/lib/account.js index a3482fbf60..d33cae6363 100644 --- a/lib/account.js +++ b/lib/account.js @@ -29,10 +29,10 @@ class Account { this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); try { const publicKey = await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId); - this._access_key = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); + this._accessKey = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); } catch { - this._access_key = null; + this._accessKey = null; } } async state() { @@ -60,10 +60,10 @@ class Account { } async signAndSendTransaction(receiverId, actions) { await this.ready; - if (this._access_key === null) { + if (this._accessKey === null) { throw new Error(`Can not sign transactions, initialize account with available public key in Signer.`); } - const [txHash, signedTx] = await transaction_1.signTransaction(receiverId, ++this._access_key.nonce, actions, this.connection.signer, this.accountId, this.connection.networkId); + const [txHash, signedTx] = await transaction_1.signTransaction(receiverId, ++this._accessKey.nonce, actions, this.connection.signer, this.accountId, this.connection.networkId); let result; try { result = await this.connection.provider.sendTransaction(signedTx); diff --git a/lib/transaction.d.ts b/lib/transaction.d.ts index 086ffaaa2f..af86d92ed1 100644 --- a/lib/transaction.d.ts +++ b/lib/transaction.d.ts @@ -80,7 +80,7 @@ declare class Transaction extends Assignable { publicKey: PublicKey; nonce: number; receiverId: string; - actions: Array; + actions: Action[]; } export declare class SignedTransaction extends Assignable { transaction: Transaction; diff --git a/lib/transaction.js b/lib/transaction.js index 364e8fae52..1d91feb8b2 100644 --- a/lib/transaction.js +++ b/lib/transaction.js @@ -7,8 +7,8 @@ const js_sha256_1 = __importDefault(require("js-sha256")); const serialize_1 = require("./utils/serialize"); class Enum { constructor(properties) { - if (Object.keys(properties).length != 1) { - throw new Error("Enum can only take single value"); + if (Object.keys(properties).length !== 1) { + throw new Error('Enum can only take single value'); } Object.keys(properties).map((key) => { this[key] = properties[key]; @@ -122,29 +122,29 @@ class Action extends Enum { } exports.Action = Action; const SCHEMA = { - 'Signature': { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }, - 'SignedTransaction': { kind: 'struct', fields: [['transaction', Transaction], ['signature', Signature]] }, - 'Transaction': { + Signature: { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }, + SignedTransaction: { kind: 'struct', fields: [['transaction', Transaction], ['signature', Signature]] }, + Transaction: { kind: 'struct', fields: [['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['actions', [Action]]] }, - 'PublicKey': { + PublicKey: { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }, - 'AccessKey': { kind: 'struct', fields: [ + AccessKey: { kind: 'struct', fields: [ ['nonce', 'u64'], ['permission', AccessKeyPermission], ] }, - 'AccessKeyPermission': { kind: 'enum', field: 'enum', values: [ + AccessKeyPermission: { kind: 'enum', field: 'enum', values: [ ['functionCall', FunctionCallPermission], ['fullAccess', FullAccessPermission], ] }, - 'FunctionCallPermission': { kind: 'struct', fields: [ + FunctionCallPermission: { kind: 'struct', fields: [ ['allowance', { kind: 'option', type: 'u128' }], ['receiverId', 'string'], ['methodNames', ['string']], ] }, - 'FullAccessPermission': { kind: 'struct', fields: [] }, - 'Action': { kind: 'enum', field: 'enum', values: [ + FullAccessPermission: { kind: 'struct', fields: [] }, + Action: { kind: 'enum', field: 'enum', values: [ ['createAccount', CreateAccount], ['deployContract', DeployContract], ['functionCall', functionCall], @@ -154,14 +154,14 @@ const SCHEMA = { ['deleteKey', deleteKey], ['deleteAccount', deleteAccount], ] }, - 'CreateAccount': { kind: 'struct', fields: [] }, - 'DeployContract': { kind: 'struct', fields: [['code', ['u8']]] }, - 'FunctionCall': { kind: 'struct', fields: [['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128']] }, - 'Transfer': { kind: 'struct', fields: [['deposit', 'u128']] }, - 'Stake': { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', PublicKey]] }, - 'AddKey': { kind: 'struct', fields: [['publicKey', PublicKey], ['accessKey', AccessKey]] }, - 'DeleteKey': { kind: 'struct', fields: [['publicKey', PublicKey]] }, - 'DeleteAccount': { kind: 'struct', fields: [['beneficiaryId', 'string']] }, + CreateAccount: { kind: 'struct', fields: [] }, + DeployContract: { kind: 'struct', fields: [['code', ['u8']]] }, + FunctionCall: { kind: 'struct', fields: [['methodName', 'string'], ['args', ['u8']], ['gas', 'u64'], ['deposit', 'u128']] }, + Transfer: { kind: 'struct', fields: [['deposit', 'u128']] }, + Stake: { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', PublicKey]] }, + AddKey: { kind: 'struct', fields: [['publicKey', PublicKey], ['accessKey', AccessKey]] }, + DeleteKey: { kind: 'struct', fields: [['publicKey', PublicKey]] }, + DeleteAccount: { kind: 'struct', fields: [['beneficiaryId', 'string']] }, }; async function signTransaction(receiverId, nonce, actions, signer, accountId, networkId) { const publicKey = new PublicKey(await signer.getPublicKey(accountId, networkId)); diff --git a/lib/utils/serialize.d.ts b/lib/utils/serialize.d.ts index 0abc4bd503..b2100acecc 100644 --- a/lib/utils/serialize.d.ts +++ b/lib/utils/serialize.d.ts @@ -14,7 +14,7 @@ export declare class BinaryWriter { private write_buffer; write_string(str: string): void; write_fixed_array(array: Uint8Array): void; - write_array(array: Array, fn: any): void; + write_array(array: any[], fn: any): void; toArray(): Uint8Array; } export declare class BinaryReader { @@ -28,7 +28,7 @@ export declare class BinaryReader { private read_buffer; read_string(): string; read_fixed_array(len: number): Uint8Array; - read_array(fn: any): Array; + read_array(fn: any): any[]; } export declare function serialize(schema: any, obj: any): Uint8Array; export declare function deserialize(schema: any, classType: any, buffer: Buffer): any; diff --git a/lib/utils/serialize.js b/lib/utils/serialize.js index 923010680c..5dd1c3f759 100644 --- a/lib/utils/serialize.js +++ b/lib/utils/serialize.js @@ -52,7 +52,7 @@ class BinaryWriter { } write_string(str) { this.maybe_resize(); - let b = Buffer.from(str, 'utf8'); + const b = Buffer.from(str, 'utf8'); this.write_u32(b.length); this.write_buffer(b); } @@ -62,9 +62,9 @@ class BinaryWriter { write_array(array, fn) { this.maybe_resize(); this.write_u32(array.length); - for (let i = 0; i < array.length; ++i) { + for (const elem of array) { this.maybe_resize(); - fn(array[i]); + fn(elem); } } toArray() { @@ -88,12 +88,12 @@ class BinaryReader { return value; } read_u64() { - let buf = this.read_buffer(8); + const buf = this.read_buffer(8); buf.reverse(); return new bn_js_1.default(`${buf.toString('hex')}`, 16); } read_u128() { - let buf = this.read_buffer(16); + const buf = this.read_buffer(16); return new bn_js_1.default(buf); } read_buffer(len) { @@ -102,7 +102,7 @@ class BinaryReader { return result; } read_string() { - let len = this.read_u32(); + const len = this.read_u32(); return this.read_buffer(len).toString('utf8'); } read_fixed_array(len) { @@ -110,7 +110,7 @@ class BinaryReader { } read_array(fn) { const len = this.read_u32(); - let result = Array(); + const result = Array(); for (let i = 0; i < len; ++i) { result.push(fn()); } @@ -119,11 +119,11 @@ class BinaryReader { } exports.BinaryReader = BinaryReader; function serializeField(schema, value, fieldType, writer) { - if (typeof fieldType === "string") { + if (typeof fieldType === 'string') { writer[`write_${fieldType}`](value); } else if (fieldType instanceof Array) { - if (typeof fieldType[0] === "number") { + if (typeof fieldType[0] === 'number') { writer.write_fixed_array(value); } else { @@ -132,7 +132,7 @@ function serializeField(schema, value, fieldType, writer) { } else if (fieldType.kind !== undefined) { switch (fieldType.kind) { - case "option": { + case 'option': { if (value === null) { writer.write_u8(0); } @@ -162,7 +162,7 @@ function serializeStruct(schema, obj, writer) { else if (schema[className].kind === 'enum') { const name = obj[schema[className].field]; for (let idx = 0; idx < schema[className].values.length; ++idx) { - let [fieldName, fieldType] = schema[className].values[idx]; + const [fieldName, fieldType] = schema[className].values[idx]; if (fieldName === name) { writer.write_u8(idx); serializeField(schema, obj[fieldName], fieldType, writer); @@ -177,13 +177,13 @@ function serializeStruct(schema, obj, writer) { /// Serialize given object using schema of the form: /// { class_name -> [ [field_name, field_type], .. ], .. } function serialize(schema, obj) { - let writer = new BinaryWriter(); + const writer = new BinaryWriter(); serializeStruct(schema, obj, writer); return writer.toArray(); } exports.serialize = serialize; function deserializeField(schema, fieldType, reader) { - if (typeof fieldType === "string") { + if (typeof fieldType === 'string') { return reader[`read_${fieldType}`](); } else if (fieldType instanceof Array) { @@ -191,7 +191,7 @@ function deserializeField(schema, fieldType, reader) { return reader.read_fixed_array(fieldType[0]); } else { - return reader.read_array(() => { return deserializeField(schema, fieldType[0], reader); }); + return reader.read_array(() => deserializeField(schema, fieldType[0], reader)); } } else { @@ -199,14 +199,14 @@ function deserializeField(schema, fieldType, reader) { } } function deserializeStruct(schema, classType, reader) { - let fields = schema[classType.name].fields.map(([fieldName, fieldType]) => { + const fields = schema[classType.name].fields.map(([fieldName, fieldType]) => { return deserializeField(schema, fieldType, reader); }); return new classType(...fields); } /// Deserializes object from bytes using schema. function deserialize(schema, classType, buffer) { - let reader = new BinaryReader(buffer); + const reader = new BinaryReader(buffer); return deserializeStruct(schema, classType, reader); } exports.deserialize = deserialize;