diff --git a/dist/nearlib.js b/dist/nearlib.js index a261d490fd..4f16e56245 100644 --- a/dist/nearlib.js +++ b/dist/nearlib.js @@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const transaction_1 = require("./transaction"); const provider_1 = require("./providers/provider"); const serialize_1 = require("./utils/serialize"); +const key_pair_1 = require("./utils/key_pair"); // 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. @@ -37,8 +38,11 @@ class Account { async fetchState() { this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); try { - const publicKey = await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId); + const publicKey = (await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId)).toString(); this._accessKey = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); + if (this._accessKey === null) { + throw new Error(`Failed to fetch access key for '${this.accountId}' with public key ${publicKey}`); + } } catch { this._accessKey = null; @@ -72,7 +76,8 @@ class Account { 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 status = await this.connection.provider.status(); + const [txHash, signedTx] = await transaction_1.signTransaction(receiverId, ++this._accessKey.nonce, actions, serialize_1.base_decode(status.sync_info.latest_block_hash), this.connection.signer, this.accountId, this.connection.networkId); let result; try { result = await this.connection.provider.sendTransaction(signedTx); @@ -98,10 +103,9 @@ class Account { return result; } async createAndDeployContract(contractId, publicKey, data, amount) { - await this.createAccount(contractId, publicKey, amount); + const accessKey = transaction_1.fullAccessKey(); + await this.signAndSendTransaction(contractId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey), transaction_1.deployContract(data)]); const contractAccount = new Account(this.connection, contractId); - await contractAccount.ready; - await contractAccount.deployContract(data); return contractAccount; } async sendMoney(receiverId, amount) { @@ -109,7 +113,7 @@ class Account { } async createAccount(newAccountId, publicKey, amount) { const accessKey = transaction_1.fullAccessKey(); - return this.signAndSendTransaction(newAccountId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(newAccountId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey)]); } async deployContract(data) { return this.signAndSendTransaction(this.accountId, [transaction_1.deployContract(data)]); @@ -129,13 +133,13 @@ class Account { else { accessKey = transaction_1.functionCallAccessKey(contractId, !methodName ? [] : [methodName], amount); } - return this.signAndSendTransaction(this.accountId, [transaction_1.addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey)]); } async deleteKey(publicKey) { - return this.signAndSendTransaction(this.accountId, [transaction_1.deleteKey(publicKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.deleteKey(key_pair_1.PublicKey.from(publicKey))]); } async stake(publicKey, amount) { - return this.signAndSendTransaction(this.accountId, [transaction_1.stake(amount, publicKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.stake(amount, key_pair_1.PublicKey.from(publicKey))]); } async viewFunction(contractId, methodName, args) { const result = await this.connection.provider.query(`call/${contractId}/${methodName}`, serialize_1.base_encode(JSON.stringify(args))); @@ -160,7 +164,7 @@ class Account { result.authorizedApps.push({ contractId: perm.receiver_id, amount: perm.allowance, - publicKey: item.public_key.data, + publicKey: item.public_key, }); } }); @@ -170,7 +174,7 @@ class Account { exports.Account = Account; }).call(this,require("buffer").Buffer) -},{"./providers/provider":16,"./transaction":18,"./utils/serialize":22,"buffer":31}],3:[function(require,module,exports){ +},{"./providers/provider":16,"./transaction":18,"./utils/key_pair":20,"./utils/serialize":22,"buffer":31}],3:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** @@ -645,17 +649,6 @@ class Near { const account = new account_1.Account(this.connection, options.sender); return new contract_1.Contract(account, contractId, options); } - /** - * Backwards compatibility method. Use `contractAccount.deployContract` or `yourAccount.createAndDeployContract` instead. - * @param contractId - * @param wasmByteArray - */ - async deployContract(contractId, wasmByteArray) { - console.warn('near.deployContract is deprecated. Use `contractAccount.deployContract` or `yourAccount.createAndDeployContract` instead.'); - const account = new account_1.Account(this.connection, contractId); - const result = await account.deployContract(wasmByteArray); - return result.logs[0].hash; - } /** * Backwards compatibility method. Use `yourAccount.sendMoney` instead. * @param amount @@ -666,7 +659,7 @@ class Near { console.warn('near.sendTokens is deprecated. Use `yourAccount.sendMoney` instead.'); const account = new account_1.Account(this.connection, originator); const result = await account.sendMoney(receiver, amount); - return result.logs[0].hash; + return result.transactions[0].hash; } } exports.Near = Near; @@ -777,10 +770,10 @@ 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()); + for (let i = txResult.transactions.length - 1; i >= 0; --i) { + const r = txResult.transactions[i]; + if (r.result && r.result.result && r.result.result.length > 0) { + return JSON.parse(Buffer.from(r.result.result, 'base64').toString()); } } return null; @@ -849,6 +842,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const js_sha256_1 = __importDefault(require("js-sha256")); const serialize_1 = require("./utils/serialize"); +const key_pair_1 = require("./utils/key_pair"); class Enum { constructor(properties) { if (Object.keys(properties).length !== 1) { @@ -923,34 +917,24 @@ function transfer(deposit) { } exports.transfer = transfer; function stake(stake, publicKey) { - return new Action({ stake: new Stake({ stake, publicKey: new PublicKey(publicKey) }) }); + return new Action({ stake: new Stake({ stake, publicKey }) }); } exports.stake = stake; function addKey(publicKey, accessKey) { - return new Action({ addKey: new AddKey({ publicKey: new PublicKey(publicKey), accessKey }) }); + return new Action({ addKey: new AddKey({ publicKey, accessKey }) }); } exports.addKey = addKey; function deleteKey(publicKey) { - return new Action({ deleteKey: new DeleteKey({ publicKey: new PublicKey(publicKey) }) }); + return new Action({ deleteKey: new DeleteKey({ 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.keyType = key_pair_1.KeyType.ED25519; this.data = signature; } } @@ -968,8 +952,8 @@ exports.Action = Action; const SCHEMA = new Map([ [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, { + [Transaction, { kind: 'struct', fields: [['signerId', 'string'], ['publicKey', key_pair_1.PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['blockHash', [32]], ['actions', [Action]]] }], + [key_pair_1.PublicKey, { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }], [AccessKey, { kind: 'struct', fields: [ @@ -1000,14 +984,14 @@ const SCHEMA = new Map([ [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]] }], + [Stake, { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', key_pair_1.PublicKey]] }], + [AddKey, { kind: 'struct', fields: [['publicKey', key_pair_1.PublicKey], ['accessKey', AccessKey]] }], + [DeleteKey, { kind: 'struct', fields: [['publicKey', key_pair_1.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 }); +async function signTransaction(receiverId, nonce, actions, blockHash, signer, accountId, networkId) { + const publicKey = await signer.getPublicKey(accountId, networkId); + const transaction = new Transaction({ signerId: accountId, publicKey, nonce, receiverId, actions, blockHash }); 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); @@ -1016,7 +1000,7 @@ async function signTransaction(receiverId, nonce, actions, signer, accountId, ne } exports.signTransaction = signTransaction; -},{"./utils/serialize":22,"js-sha256":50}],19:[function(require,module,exports){ +},{"./utils/key_pair":20,"./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; @@ -1046,21 +1030,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const tweetnacl_1 = __importDefault(require("tweetnacl")); const serialize_1 = require("./serialize"); +/** All supported key types */ +var KeyType; +(function (KeyType) { + KeyType[KeyType["ED25519"] = 0] = "ED25519"; +})(KeyType = exports.KeyType || (exports.KeyType = {})); +function key_type_to_str(key_type) { + switch (key_type) { + case KeyType.ED25519: return 'ED25519'; + default: throw new Error(`Unknown key type ${key_type}`); + } +} +function str_to_key_type(key_type) { + switch (key_type.toUpperCase()) { + case 'ED25519': return KeyType.ED25519; + default: throw new Error(`Unknown key type ${key_type}`); + } +} +/** + * PublicKey representation that has type and bytes of the key. + */ +class PublicKey { + constructor(keyType, data) { + this.keyType = keyType; + this.data = data; + } + static from(value) { + if (typeof value === 'string') { + return PublicKey.fromString(value); + } + return value; + } + static fromString(encodedKey) { + const parts = encodedKey.split(':'); + if (parts.length == 1) { + return new PublicKey(KeyType.ED25519, serialize_1.base_decode(parts[0])); + } + else if (parts.length == 2) { + return new PublicKey(str_to_key_type(parts[0]), serialize_1.base_decode(parts[1])); + } + else { + throw new Error('Invlaid encoded key format, must be :'); + } + } + toString() { + return `${key_type_to_str(this.keyType)}:${serialize_1.base_encode(this.data)}`; + } +} +exports.PublicKey = PublicKey; class KeyPair { static fromRandom(curve) { - switch (curve) { - case 'ed25519': return KeyPairEd25519.fromRandom(); + switch (curve.toUpperCase()) { + 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 :'); + if (parts.length == 1) { + return new KeyPairEd25519(parts[0]); } - switch (parts[0]) { - case 'ed25519': return new KeyPairEd25519(parts[1]); - default: throw new Error(`Unknown curve: ${parts[0]}`); + else if (parts.length == 2) { + switch (parts[0].toUpperCase()) { + case 'ED25519': return new KeyPairEd25519(parts[1]); + default: throw new Error(`Unknown curve: ${parts[0]}`); + } + } + else { + throw new Error('Invalid encoded key format, must be :'); } } } @@ -1078,7 +1115,7 @@ class KeyPairEd25519 extends KeyPair { 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.publicKey = new PublicKey(KeyType.ED25519, keyPair.publicKey); this.secretKey = secretKey; } /** @@ -1100,7 +1137,7 @@ class KeyPairEd25519 extends KeyPair { return { signature, publicKey: this.publicKey }; } verify(message, signature) { - return tweetnacl_1.default.sign.detached.verify(message, signature, serialize_1.base_decode(this.publicKey)); + return tweetnacl_1.default.sign.detached.verify(message, signature, this.publicKey.data); } toString() { return `ed25519:${this.secretKey}`; @@ -1420,7 +1457,7 @@ class WalletAccount { 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()); + newUrl.searchParams.set('public_key', accessKey.getPublicKey().toString()); await this._keyStore.setKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + accessKey.getPublicKey(), accessKey); window.location.assign(newUrl.toString()); } @@ -6984,124 +7021,124 @@ function numberIsNaN (obj) { },{"base64-js":26,"buffer":31,"ieee754":48}],32:[function(require,module,exports){ require(".").check("es5"); },{".":33}],33:[function(require,module,exports){ -require("./lib/definitions"); -module.exports = require("./lib"); +require("./lib/definitions"); +module.exports = require("./lib"); },{"./lib":36,"./lib/definitions":35}],34:[function(require,module,exports){ -var CapabilityDetector = function () { - this.tests = {}; - this.cache = {}; -}; -CapabilityDetector.prototype = { - constructor: CapabilityDetector, - define: function (name, test) { - if (typeof (name) != "string" || !(test instanceof Function)) - throw new Error("Invalid capability definition."); - if (this.tests[name]) - throw new Error('Duplicated capability definition by "' + name + '".'); - this.tests[name] = test; - }, - check: function (name) { - if (!this.test(name)) - throw new Error('The current environment does not support "' + name + '", therefore we cannot continue.'); - }, - test: function (name) { - if (this.cache[name] !== undefined) - return this.cache[name]; - if (!this.tests[name]) - throw new Error('Unknown capability with name "' + name + '".'); - var test = this.tests[name]; - this.cache[name] = !!test(); - return this.cache[name]; - } -}; - +var CapabilityDetector = function () { + this.tests = {}; + this.cache = {}; +}; +CapabilityDetector.prototype = { + constructor: CapabilityDetector, + define: function (name, test) { + if (typeof (name) != "string" || !(test instanceof Function)) + throw new Error("Invalid capability definition."); + if (this.tests[name]) + throw new Error('Duplicated capability definition by "' + name + '".'); + this.tests[name] = test; + }, + check: function (name) { + if (!this.test(name)) + throw new Error('The current environment does not support "' + name + '", therefore we cannot continue.'); + }, + test: function (name) { + if (this.cache[name] !== undefined) + return this.cache[name]; + if (!this.tests[name]) + throw new Error('Unknown capability with name "' + name + '".'); + var test = this.tests[name]; + this.cache[name] = !!test(); + return this.cache[name]; + } +}; + module.exports = CapabilityDetector; },{}],35:[function(require,module,exports){ -var capability = require("."), - define = capability.define, - test = capability.test; - -define("strict mode", function () { - return (this === undefined); -}); - -define("arguments.callee.caller", function () { - try { - return (function () { - return arguments.callee.caller; - })() === arguments.callee; - } catch (strictModeIsEnforced) { - return false; - } -}); - -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; - } +var capability = require("."), + define = capability.define, + test = capability.test; + +define("strict mode", function () { + return (this === undefined); +}); + +define("arguments.callee.caller", function () { + try { + return (function () { + return arguments.callee.caller; + })() === arguments.callee; + } catch (strictModeIsEnforced) { + return false; + } +}); + +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; + } }); },{".":36}],36:[function(require,module,exports){ -var CapabilityDetector = require("./CapabilityDetector"); - -var detector = new CapabilityDetector(); - -var capability = function (name) { - return detector.test(name); -}; -capability.define = function (name, test) { - detector.define(name, test); -}; -capability.check = function (name) { - detector.check(name); -}; -capability.test = capability; - +var CapabilityDetector = require("./CapabilityDetector"); + +var detector = new CapabilityDetector(); + +var capability = function (name) { + return detector.test(name); +}; +capability.define = function (name, test) { + detector.define(name, test); +}; +capability.check = function (name) { + detector.check(name); +}; +capability.test = capability; + module.exports = capability; },{"./CapabilityDetector":34}],37:[function(require,module,exports){ /*! @@ -7185,377 +7222,377 @@ function wrapproperty (obj, prop, message) { },{}],38:[function(require,module,exports){ module.exports = require("./lib"); },{"./lib":39}],39:[function(require,module,exports){ -require("capability/es5"); - -var capability = require("capability"); - -var polyfill; -if (capability("Error.captureStackTrace")) - polyfill = require("./v8"); -else if (capability("Error.prototype.stack")) - polyfill = require("./non-v8/index"); -else - polyfill = require("./unsupported"); - +require("capability/es5"); + +var capability = require("capability"); + +var polyfill; +if (capability("Error.captureStackTrace")) + polyfill = require("./v8"); +else if (capability("Error.prototype.stack")) + polyfill = require("./non-v8/index"); +else + polyfill = require("./unsupported"); + module.exports = polyfill(); },{"./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; - -var Frame = Class(Object, { - prototype: { - init: Class.prototype.merge, - frameString: undefined, - toString: function () { - return this.frameString; - }, - functionValue: undefined, - 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 - } -}); - +var Class = require("o3").Class, + abstractMethod = require("o3").abstractMethod; + +var Frame = Class(Object, { + prototype: { + init: Class.prototype.merge, + frameString: undefined, + toString: function () { + return this.frameString; + }, + functionValue: undefined, + 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":51}],41:[function(require,module,exports){ -var Class = require("o3").Class, - Frame = require("./Frame"), - cache = require("u3").cache; - -var FrameStringParser = Class(Object, { - prototype: { - stackParser: null, - frameParser: null, - locationParsers: null, - constructor: function (options) { - Class.prototype.merge.call(this, options); - }, - getFrames: function (frameStrings, functionValues) { - var frames = []; - for (var index = 0, length = frameStrings.length; index < length; ++index) - frames[index] = this.getFrame(frameStrings[index], functionValues[index]); - return frames; - }, - getFrame: function (frameString, functionValue) { - var config = { - frameString: frameString, - functionValue: functionValue - }; - return new Frame(config); - } - } -}); - -module.exports = { - getClass: cache(function () { - return FrameStringParser; - }), - getInstance: cache(function () { - var FrameStringParser = this.getClass(); - var instance = new FrameStringParser(); - return instance; - }) +var Class = require("o3").Class, + Frame = require("./Frame"), + cache = require("u3").cache; + +var FrameStringParser = Class(Object, { + prototype: { + stackParser: null, + frameParser: null, + locationParsers: null, + constructor: function (options) { + Class.prototype.merge.call(this, options); + }, + getFrames: function (frameStrings, functionValues) { + var frames = []; + for (var index = 0, length = frameStrings.length; index < length; ++index) + frames[index] = this.getFrame(frameStrings[index], functionValues[index]); + return frames; + }, + getFrame: function (frameString, functionValue) { + var config = { + frameString: frameString, + functionValue: functionValue + }; + return new Frame(config); + } + } +}); + +module.exports = { + getClass: cache(function () { + return FrameStringParser; + }), + getInstance: cache(function () { + var FrameStringParser = this.getClass(); + var instance = new FrameStringParser(); + return instance; + }) }; },{"./Frame":40,"o3":51,"u3":62}],42:[function(require,module,exports){ -var Class = require("o3").Class, - abstractMethod = require("o3").abstractMethod, - eachCombination = require("u3").eachCombination, - cache = require("u3").cache, - capability = require("capability"); - -var AbstractFrameStringSource = Class(Object, { - prototype: { - captureFrameStrings: function (frameShifts) { - var error = this.createError(); - frameShifts.unshift(this.captureFrameStrings); - frameShifts.unshift(this.createError); - var capturedFrameStrings = this.getFrameStrings(error); - - var frameStrings = capturedFrameStrings.slice(frameShifts.length), - functionValues = []; - - if (capability("arguments.callee.caller")) { - var capturedFunctionValues = [ - this.createError, - this.captureFrameStrings - ]; - try { - var aCaller = arguments.callee; - while (aCaller = aCaller.caller) - capturedFunctionValues.push(aCaller); - } - catch (useStrictError) { - } - functionValues = capturedFunctionValues.slice(frameShifts.length); - } - return { - frameStrings: frameStrings, - functionValues: functionValues - }; - }, - getFrameStrings: function (error) { - var message = error.message || ""; - var name = error.name || ""; - var stackString = this.getStackString(error); - if (stackString === undefined) - return; - var stackStringChunks = stackString.split("\n"); - var fromPosition = 0; - var toPosition = stackStringChunks.length; - if (this.hasHeader) - fromPosition += name.split("\n").length + message.split("\n").length - 1; - if (this.hasFooter) - toPosition -= 1; - return stackStringChunks.slice(fromPosition, toPosition); - }, - createError: abstractMethod, - getStackString: abstractMethod, - hasHeader: undefined, - hasFooter: undefined - } -}); - -var FrameStringSourceCalibrator = Class(Object, { - prototype: { - calibrateClass: function (FrameStringSource) { - return this.calibrateMethods(FrameStringSource) && this.calibrateEnvelope(FrameStringSource); - }, - calibrateMethods: function (FrameStringSource) { - try { - eachCombination([[ - function (message) { - return new Error(message); - }, - function (message) { - try { - throw new Error(message); - } - catch (error) { - return error; - } - } - ], [ - function (error) { - return error.stack; - }, - function (error) { - return error.stacktrace; - } - ]], function (createError, getStackString) { - if (getStackString(createError())) - throw { - getStackString: getStackString, - createError: createError - }; - }); - } catch (workingImplementation) { - Class.merge.call(FrameStringSource, { - prototype: workingImplementation - }); - return true; - } - return false; - }, - calibrateEnvelope: function (FrameStringSource) { - var getStackString = FrameStringSource.prototype.getStackString; - var createError = FrameStringSource.prototype.createError; - var calibratorStackString = getStackString(createError("marker")); - var calibratorFrameStrings = calibratorStackString.split("\n"); - Class.merge.call(FrameStringSource, { - prototype: { - hasHeader: /marker/.test(calibratorFrameStrings[0]), - hasFooter: calibratorFrameStrings[calibratorFrameStrings.length - 1] === "" - } - }); - return true; - } - } -}); - - -module.exports = { - getClass: cache(function () { - var FrameStringSource; - if (FrameStringSource) - return FrameStringSource; - FrameStringSource = Class(AbstractFrameStringSource, {}); - var calibrator = new FrameStringSourceCalibrator(); - if (!calibrator.calibrateClass(FrameStringSource)) - throw new Error("Cannot read Error.prototype.stack in this environment."); - return FrameStringSource; - }), - getInstance: cache(function () { - var FrameStringSource = this.getClass(); - var instance = new FrameStringSource(); - return instance; - }) +var Class = require("o3").Class, + abstractMethod = require("o3").abstractMethod, + eachCombination = require("u3").eachCombination, + cache = require("u3").cache, + capability = require("capability"); + +var AbstractFrameStringSource = Class(Object, { + prototype: { + captureFrameStrings: function (frameShifts) { + var error = this.createError(); + frameShifts.unshift(this.captureFrameStrings); + frameShifts.unshift(this.createError); + var capturedFrameStrings = this.getFrameStrings(error); + + var frameStrings = capturedFrameStrings.slice(frameShifts.length), + functionValues = []; + + if (capability("arguments.callee.caller")) { + var capturedFunctionValues = [ + this.createError, + this.captureFrameStrings + ]; + try { + var aCaller = arguments.callee; + while (aCaller = aCaller.caller) + capturedFunctionValues.push(aCaller); + } + catch (useStrictError) { + } + functionValues = capturedFunctionValues.slice(frameShifts.length); + } + return { + frameStrings: frameStrings, + functionValues: functionValues + }; + }, + getFrameStrings: function (error) { + var message = error.message || ""; + var name = error.name || ""; + var stackString = this.getStackString(error); + if (stackString === undefined) + return; + var stackStringChunks = stackString.split("\n"); + var fromPosition = 0; + var toPosition = stackStringChunks.length; + if (this.hasHeader) + fromPosition += name.split("\n").length + message.split("\n").length - 1; + if (this.hasFooter) + toPosition -= 1; + return stackStringChunks.slice(fromPosition, toPosition); + }, + createError: abstractMethod, + getStackString: abstractMethod, + hasHeader: undefined, + hasFooter: undefined + } +}); + +var FrameStringSourceCalibrator = Class(Object, { + prototype: { + calibrateClass: function (FrameStringSource) { + return this.calibrateMethods(FrameStringSource) && this.calibrateEnvelope(FrameStringSource); + }, + calibrateMethods: function (FrameStringSource) { + try { + eachCombination([[ + function (message) { + return new Error(message); + }, + function (message) { + try { + throw new Error(message); + } + catch (error) { + return error; + } + } + ], [ + function (error) { + return error.stack; + }, + function (error) { + return error.stacktrace; + } + ]], function (createError, getStackString) { + if (getStackString(createError())) + throw { + getStackString: getStackString, + createError: createError + }; + }); + } catch (workingImplementation) { + Class.merge.call(FrameStringSource, { + prototype: workingImplementation + }); + return true; + } + return false; + }, + calibrateEnvelope: function (FrameStringSource) { + var getStackString = FrameStringSource.prototype.getStackString; + var createError = FrameStringSource.prototype.createError; + var calibratorStackString = getStackString(createError("marker")); + var calibratorFrameStrings = calibratorStackString.split("\n"); + Class.merge.call(FrameStringSource, { + prototype: { + hasHeader: /marker/.test(calibratorFrameStrings[0]), + hasFooter: calibratorFrameStrings[calibratorFrameStrings.length - 1] === "" + } + }); + return true; + } + } +}); + + +module.exports = { + getClass: cache(function () { + var FrameStringSource; + if (FrameStringSource) + return FrameStringSource; + FrameStringSource = Class(AbstractFrameStringSource, {}); + var calibrator = new FrameStringSourceCalibrator(); + if (!calibrator.calibrateClass(FrameStringSource)) + throw new Error("Cannot read Error.prototype.stack in this environment."); + return FrameStringSource; + }), + getInstance: cache(function () { + var FrameStringSource = this.getClass(); + var instance = new FrameStringSource(); + return instance; + }) }; },{"capability":33,"o3":51,"u3":62}],43:[function(require,module,exports){ -var FrameStringSource = require("./FrameStringSource"), - FrameStringParser = require("./FrameStringParser"), - cache = require("u3").cache, - prepareStackTrace = require("../prepareStackTrace"); - -module.exports = function () { - - Error.captureStackTrace = function captureStackTrace(throwable, terminator) { - var warnings; - var frameShifts = [ - captureStackTrace - ]; - if (terminator) { - // additional frames can come here if arguments.callee.caller is supported - // otherwise it is hard to identify the terminator - frameShifts.push(terminator); - } - var captured = FrameStringSource.getInstance().captureFrameStrings(frameShifts); - Object.defineProperties(throwable, { - stack: { - configurable: true, - get: cache(function () { - var frames = FrameStringParser.getInstance().getFrames(captured.frameStrings, captured.functionValues); - return (Error.prepareStackTrace || prepareStackTrace)(throwable, frames, warnings); - }) - }, - cachedStack: { - configurable: true, - writable: true, - enumerable: false, - value: true - } - }); - }; - - Error.getStackTrace = function (throwable) { - if (throwable.cachedStack) - return throwable.stack; - var frameStrings = FrameStringSource.getInstance().getFrameStrings(throwable), - frames = [], - warnings; - if (frameStrings) - frames = FrameStringParser.getInstance().getFrames(frameStrings, []); - else - warnings = [ - "The stack is not readable by unthrown errors in this environment." - ]; - var stack = (Error.prepareStackTrace || prepareStackTrace)(throwable, frames, warnings); - if (frameStrings) - try { - Object.defineProperties(throwable, { - stack: { - configurable: true, - writable: true, - enumerable: false, - value: stack - }, - cachedStack: { - configurable: true, - writable: true, - enumerable: false, - value: true - } - }); - } catch (nonConfigurableError) { - } - return stack; - }; - - return { - prepareStackTrace: prepareStackTrace - }; +var FrameStringSource = require("./FrameStringSource"), + FrameStringParser = require("./FrameStringParser"), + cache = require("u3").cache, + prepareStackTrace = require("../prepareStackTrace"); + +module.exports = function () { + + Error.captureStackTrace = function captureStackTrace(throwable, terminator) { + var warnings; + var frameShifts = [ + captureStackTrace + ]; + if (terminator) { + // additional frames can come here if arguments.callee.caller is supported + // otherwise it is hard to identify the terminator + frameShifts.push(terminator); + } + var captured = FrameStringSource.getInstance().captureFrameStrings(frameShifts); + Object.defineProperties(throwable, { + stack: { + configurable: true, + get: cache(function () { + var frames = FrameStringParser.getInstance().getFrames(captured.frameStrings, captured.functionValues); + return (Error.prepareStackTrace || prepareStackTrace)(throwable, frames, warnings); + }) + }, + cachedStack: { + configurable: true, + writable: true, + enumerable: false, + value: true + } + }); + }; + + Error.getStackTrace = function (throwable) { + if (throwable.cachedStack) + return throwable.stack; + var frameStrings = FrameStringSource.getInstance().getFrameStrings(throwable), + frames = [], + warnings; + if (frameStrings) + frames = FrameStringParser.getInstance().getFrames(frameStrings, []); + else + warnings = [ + "The stack is not readable by unthrown errors in this environment." + ]; + var stack = (Error.prepareStackTrace || prepareStackTrace)(throwable, frames, warnings); + if (frameStrings) + try { + Object.defineProperties(throwable, { + stack: { + configurable: true, + writable: true, + enumerable: false, + value: stack + }, + cachedStack: { + configurable: true, + writable: true, + enumerable: false, + value: true + } + }); + } catch (nonConfigurableError) { + } + return stack; + }; + + return { + prepareStackTrace: prepareStackTrace + }; }; },{"../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"; - string += ": " + (throwable.message || ""); - if (warnings instanceof Array) - for (var warningIndex in warnings) { - var warning = warnings[warningIndex]; - string += "\n # " + warning; - } - for (var frameIndex in frames) { - var frame = frames[frameIndex]; - string += "\n at " + frame.toString(); - } - return string; -}; - +var prepareStackTrace = function (throwable, frames, warnings) { + var string = ""; + string += throwable.name || "Error"; + string += ": " + (throwable.message || ""); + if (warnings instanceof Array) + for (var warningIndex in warnings) { + var warning = warnings[warningIndex]; + string += "\n # " + warning; + } + for (var frameIndex in frames) { + var frame = frames[frameIndex]; + string += "\n at " + frame.toString(); + } + return string; +}; + module.exports = prepareStackTrace; },{}],45:[function(require,module,exports){ -var cache = require("u3").cache, - prepareStackTrace = require("./prepareStackTrace"); - -module.exports = function () { - - Error.captureStackTrace = function (throwable, terminator) { - Object.defineProperties(throwable, { - stack: { - configurable: true, - get: cache(function () { - return (Error.prepareStackTrace || prepareStackTrace)(throwable, []); - }) - }, - cachedStack: { - configurable: true, - writable: true, - enumerable: false, - value: true - } - }); - }; - - Error.getStackTrace = function (throwable) { - if (throwable.cachedStack) - return throwable.stack; - var stack = (Error.prepareStackTrace || prepareStackTrace)(throwable, []); - try { - Object.defineProperties(throwable, { - stack: { - configurable: true, - writable: true, - enumerable: false, - value: stack - }, - cachedStack: { - configurable: true, - writable: true, - enumerable: false, - value: true - } - }); - } catch (nonConfigurableError) { - } - return stack; - }; - - return { - prepareStackTrace: prepareStackTrace - }; +var cache = require("u3").cache, + prepareStackTrace = require("./prepareStackTrace"); + +module.exports = function () { + + Error.captureStackTrace = function (throwable, terminator) { + Object.defineProperties(throwable, { + stack: { + configurable: true, + get: cache(function () { + return (Error.prepareStackTrace || prepareStackTrace)(throwable, []); + }) + }, + cachedStack: { + configurable: true, + writable: true, + enumerable: false, + value: true + } + }); + }; + + Error.getStackTrace = function (throwable) { + if (throwable.cachedStack) + return throwable.stack; + var stack = (Error.prepareStackTrace || prepareStackTrace)(throwable, []); + try { + Object.defineProperties(throwable, { + stack: { + configurable: true, + writable: true, + enumerable: false, + value: stack + }, + cachedStack: { + configurable: true, + writable: true, + enumerable: false, + value: true + } + }); + } catch (nonConfigurableError) { + } + return stack; + }; + + return { + 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 - }; +var prepareStackTrace = require("./prepareStackTrace"); + +module.exports = function () { + Error.getStackTrace = function (throwable) { + return throwable.stack; + }; + + return { + prepareStackTrace: prepareStackTrace + }; }; },{"./prepareStackTrace":44}],47:[function(require,module,exports){ /*! @@ -8459,152 +8496,152 @@ if (typeof Object.create === 'function') { }).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"); - +require("capability/es5"); + 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: [] - }); - - 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; -}; - +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; },{}],53:[function(require,module,exports){ -module.exports = function () { - throw new Error("Not implemented."); +module.exports = function () { + throw new Error("Not implemented."); }; },{}],54:[function(require,module,exports){ -module.exports = { - Class: require("./Class"), - abstractMethod: require("./abstractMethod") +module.exports = { + Class: require("./Class"), + abstractMethod: require("./abstractMethod") }; },{"./Class":52,"./abstractMethod":53}],55:[function(require,module,exports){ // shim for using process in browser @@ -11472,46 +11509,46 @@ nacl.setPRNG = function(fn) { },{"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; - - if (!(fn instanceof Function)) { - called = true; - store = fn; - delete(fn); - } - - return function () { - if (!called) { - called = true; - store = fn.apply(this, arguments); - delete(fn); - } - return store; - }; -}; - +var cache = function (fn) { + var called = false, + store; + + if (!(fn instanceof Function)) { + called = true; + store = fn; + delete(fn); + } + + return function () { + if (!called) { + called = true; + store = fn.apply(this, arguments); + delete(fn); + } + return store; + }; +}; + module.exports = cache; },{}],64:[function(require,module,exports){ -module.exports = function eachCombination(alternativesByDimension, callback, combination) { - if (!combination) - combination = []; - if (combination.length < alternativesByDimension.length) { - var alternatives = alternativesByDimension[combination.length]; - for (var index in alternatives) { - combination[combination.length] = alternatives[index]; - eachCombination(alternativesByDimension, callback, combination); - --combination.length; - } - } - else - callback.apply(null, combination); +module.exports = function eachCombination(alternativesByDimension, callback, combination) { + if (!combination) + combination = []; + if (combination.length < alternativesByDimension.length) { + var alternatives = alternativesByDimension[combination.length]; + for (var index in alternatives) { + combination[combination.length] = alternatives[index]; + eachCombination(alternativesByDimension, callback, combination); + --combination.length; + } + } + else + callback.apply(null, combination); }; },{}],65:[function(require,module,exports){ -module.exports = { - cache: require("./cache"), - eachCombination: require("./eachCombination") +module.exports = { + cache: require("./cache"), + eachCombination: require("./eachCombination") }; },{"./cache":63,"./eachCombination":64}],66:[function(require,module,exports){ module.exports = function isBuffer(arg) { diff --git a/dist/nearlib.min.js b/dist/nearlib.min.js index 371a335250..b13295404d 100644 --- a/dist/nearlib.min.js +++ b/dist/nearlib.min.js @@ -5,10 +5,10 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Bu }).call(this,require("buffer").Buffer) },{"./lib/index":6,"buffer":31,"error-polyfill":38}],2:[function(require,module,exports){ (function (Buffer){ -"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; +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const transaction_1=require("./transaction"),provider_1=require("./providers/provider"),serialize_1=require("./utils/serialize"),key_pair_1=require("./utils/key_pair"),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)).toString();if(this._accessKey=await this.connection.provider.query(`access_key/${this.accountId}/${t}`,""),null===this._accessKey)throw new Error(`Failed to fetch access key for '${this.accountId}' with public key ${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(a.transaction.receiverId,c),i.status===provider_1.FinalTransactionStatus.Failed&&c){const t=c.find(t=>t.startsWith("ABORT:"))||c.find(t=>t.startsWith("Runtime error:"))||"";throw new Error(`Transaction ${i.transactions[0].hash} failed. ${t}`)}return i}async createAndDeployContract(t,n,e,s){const a=transaction_1.fullAccessKey();return await this.signAndSendTransaction(t,[transaction_1.createAccount(),transaction_1.transfer(s),transaction_1.addKey(key_pair_1.PublicKey.from(n),a),transaction_1.deployContract(e)]),new Account(this.connection,t)}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(key_pair_1.PublicKey.from(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(key_pair_1.PublicKey.from(t),a)])}async deleteKey(t){return this.signAndSendTransaction(this.accountId,[transaction_1.deleteKey(key_pair_1.PublicKey.from(t))])}async stake(t,n){return this.signAndSendTransaction(this.accountId,[transaction_1.stake(n,key_pair_1.PublicKey.from(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})}}),n}}exports.Account=Account; }).call(this,require("buffer").Buffer) -},{"./providers/provider":16,"./transaction":18,"./utils/serialize":22,"buffer":31}],3:[function(require,module,exports){ +},{"./providers/provider":16,"./transaction":18,"./utils/key_pair":20,"./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){ @@ -39,7 +39,7 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Bu "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":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 o=new account_1.Account(this.connection,t);return(await o.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=key_pair_1.KeyPair.fromString(t.secret_key),o=new key_stores_1.InMemoryKeyStore;await o.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,o]),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; +"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 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)).transactions[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=key_pair_1.KeyPair.fromString(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":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; @@ -51,20 +51,20 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Bu }).call(this,require("buffer").Buffer) },{"../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; +"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.transactions.length-1;e>=0;--e){const r=t.transactions[e];if(r.result&&r.result.result&&r.result.result.length>0)return JSON.parse(Buffer.from(r.result.result,"base64").toString())}return null}exports.Provider=Provider,exports.getTransactionLastResult=getTransactionLastResult; }).call(this,require("buffer").Buffer) },{"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":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=new Map([[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; +"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"),key_pair_1=require("./utils/key_pair");class Enum{constructor(e){if(1!==Object.keys(e).length)throw new Error("Enum can only take single value");Object.keys(e).map(s=>{this[s]=e[s],this.enum=s})}}class Assignable{constructor(e){Object.keys(e).map(s=>{this[s]=e[s]})}}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,s,n){return new AccessKey({nonce:0,permission:new AccessKeyPermission({functionCall:new FunctionCallPermission({receiverId:e,allowance:n,methodNames:s})})})}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,s,n,t){return new Action({functionCall:new FunctionCall({methodName:e,args:s,gas:n,deposit:t})})}function transfer(e){return new Action({transfer:new Transfer({deposit:e})})}function stake(e,s){return new Action({stake:new Stake({stake:e,publicKey:s})})}function addKey(e,s){return new Action({addKey:new AddKey({publicKey:e,accessKey:s})})}function deleteKey(e){return new Action({deleteKey:new DeleteKey({publicKey:e})})}function deleteAccount(e){return new Action({deleteAccount:new DeleteAccount({beneficiaryId:e})})}exports.createAccount=createAccount,exports.deployContract=deployContract,exports.functionCall=functionCall,exports.transfer=transfer,exports.stake=stake,exports.addKey=addKey,exports.deleteKey=deleteKey,exports.deleteAccount=deleteAccount;class Signature{constructor(e){this.keyType=key_pair_1.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=new Map([[Signature,{kind:"struct",fields:[["keyType","u8"],["data",[32]]]}],[SignedTransaction,{kind:"struct",fields:[["transaction",Transaction],["signature",Signature]]}],[Transaction,{kind:"struct",fields:[["signerId","string"],["publicKey",key_pair_1.PublicKey],["nonce","u64"],["receiverId","string"],["blockHash",[32]],["actions",[Action]]]}],[key_pair_1.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",key_pair_1.PublicKey]]}],[AddKey,{kind:"struct",fields:[["publicKey",key_pair_1.PublicKey],["accessKey",AccessKey]]}],[DeleteKey,{kind:"struct",fields:[["publicKey",key_pair_1.PublicKey]]}],[DeleteAccount,{kind:"struct",fields:[["beneficiaryId","string"]]}]]);async function signTransaction(e,s,n,t,c,i,r){const a=await c.getPublicKey(i,r),o=new Transaction({signerId:i,publicKey:a,nonce:s,receiverId:e,actions:n,blockHash:t}),l=serialize_1.serialize(SCHEMA,o),u=new Uint8Array(js_sha256_1.default.sha256.array(l)),d=await c.signHash(u,i,r);return[u,new SignedTransaction({transaction:o,signature:new Signature(d.signature)})]}exports.signTransaction=signTransaction; -},{"./utils/serialize":22,"js-sha256":50}],19:[function(require,module,exports){ +},{"./utils/key_pair":20,"./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":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; +"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");var KeyType;function key_type_to_str(e){switch(e){case KeyType.ED25519:return"ED25519";default:throw new Error(`Unknown key type ${e}`)}}function str_to_key_type(e){switch(e.toUpperCase()){case"ED25519":return KeyType.ED25519;default:throw new Error(`Unknown key type ${e}`)}}!function(e){e[e.ED25519=0]="ED25519"}(KeyType=exports.KeyType||(exports.KeyType={}));class PublicKey{constructor(e,t){this.keyType=e,this.data=t}static from(e){return"string"==typeof e?PublicKey.fromString(e):e}static fromString(e){const t=e.split(":");if(1==t.length)return new PublicKey(KeyType.ED25519,serialize_1.base_decode(t[0]));if(2==t.length)return new PublicKey(str_to_key_type(t[0]),serialize_1.base_decode(t[1]));throw new Error("Invlaid encoded key format, must be :")}toString(){return`${key_type_to_str(this.keyType)}:${serialize_1.base_encode(this.data)}`}}exports.PublicKey=PublicKey;class KeyPair{static fromRandom(e){switch(e.toUpperCase()){case"ED25519":return KeyPairEd25519.fromRandom();default:throw new Error(`Unknown curve ${e}`)}}static fromString(e){const t=e.split(":");if(1==t.length)return new KeyPairEd25519(t[0]);if(2!=t.length)throw new Error("Invalid encoded key format, must be :");switch(t[0].toUpperCase()){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=new PublicKey(KeyType.ED25519,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,this.publicKey.data)}toString(){return`ed25519:${this.secretKey}`}getPublicKey(){return this.publicKey}}exports.KeyPairEd25519=KeyPairEd25519; },{"./serialize":22,"tweetnacl":61}],21:[function(require,module,exports){ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}); @@ -78,7 +78,7 @@ require("error-polyfill"),window.nearlib=require("./lib/index"),window.Buffer=Bu "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":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; +"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().toString()),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":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(;u @@ -42,7 +42,7 @@ ___ **● _ready**: *`Promise`<`void`>* -*Defined in [account.ts:42](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L42)* +*Defined in [account.ts:43](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L43)* ___ @@ -51,7 +51,7 @@ ___ **● _state**: *[AccountState](../interfaces/_account_.accountstate.md)* -*Defined in [account.ts:39](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L39)* +*Defined in [account.ts:40](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L40)* ___ @@ -60,7 +60,7 @@ ___ **● accountId**: *`string`* -*Defined in [account.ts:38](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L38)* +*Defined in [account.ts:39](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L39)* ___ @@ -69,7 +69,7 @@ ___ **● connection**: *[Connection](_connection_.connection.md)* -*Defined in [account.ts:37](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L37)* +*Defined in [account.ts:38](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L38)* ___ @@ -81,7 +81,7 @@ ___ **get ready**(): `Promise`<`void`> -*Defined in [account.ts:43](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L43)* +*Defined in [account.ts:44](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L44)* **Returns:** `Promise`<`void`> @@ -93,15 +93,15 @@ ___ ## addKey -▸ **addKey**(publicKey: *`string`*, contractId?: *`string`*, methodName?: *`string`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **addKey**(publicKey: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*, contractId?: *`string`*, methodName?: *`string`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:150](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L150)* +*Defined in [account.ts:157](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L157)* **Parameters:** | Name | Type | | ------ | ------ | -| publicKey | `string` | +| publicKey | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | | `Optional` contractId | `string` | | `Optional` methodName | `string` | | `Optional` amount | `BN` | @@ -113,16 +113,16 @@ ___ ## createAccount -▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:133](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L133)* +*Defined in [account.ts:140](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L140)* **Parameters:** | Name | Type | | ------ | ------ | | newAccountId | `string` | -| publicKey | `string` | +| publicKey | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | | amount | `BN` | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -132,16 +132,16 @@ ___ ## createAndDeployContract -▸ **createAndDeployContract**(contractId: *`string`*, publicKey: *`string`*, data: *`Uint8Array`*, amount: *`BN`*): `Promise`<[Account](_account_.account.md)> +▸ **createAndDeployContract**(contractId: *`string`*, publicKey: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*, data: *`Uint8Array`*, amount: *`BN`*): `Promise`<[Account](_account_.account.md)> -*Defined in [account.ts:121](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L121)* +*Defined in [account.ts:129](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L129)* **Parameters:** | Name | Type | | ------ | ------ | | contractId | `string` | -| publicKey | `string` | +| publicKey | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | | data | `Uint8Array` | | amount | `BN` | @@ -152,15 +152,15 @@ ___ ## deleteKey -▸ **deleteKey**(publicKey: *`string`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **deleteKey**(publicKey: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:160](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L160)* +*Defined in [account.ts:167](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L167)* **Parameters:** | Name | Type | | ------ | ------ | -| publicKey | `string` | +| publicKey | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -171,7 +171,7 @@ ___ ▸ **deployContract**(data: *`Uint8Array`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:138](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L138)* +*Defined in [account.ts:145](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L145)* **Parameters:** @@ -188,7 +188,7 @@ ___ ▸ **fetchState**(): `Promise`<`void`> -*Defined in [account.ts:52](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L52)* +*Defined in [account.ts:53](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L53)* **Returns:** `Promise`<`void`> @@ -199,7 +199,7 @@ ___ ▸ **functionCall**(contractId: *`string`*, methodName: *`string`*, args: *`any`*, gas: *`number`*, amount?: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:142](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L142)* +*Defined in [account.ts:149](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L149)* **Parameters:** @@ -220,7 +220,7 @@ ___ ▸ **getAccessKeys**(): `Promise`<`any`> -*Defined in [account.ts:177](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L177)* +*Defined in [account.ts:184](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L184)* **Returns:** `Promise`<`any`> @@ -231,7 +231,7 @@ ___ ▸ **getAccountDetails**(): `Promise`<`any`> -*Defined in [account.ts:182](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L182)* +*Defined in [account.ts:189](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L189)* **Returns:** `Promise`<`any`> @@ -242,7 +242,7 @@ ___ ▸ **printLogs**(contractId: *`string`*, logs: *`string`[]*): `void` -*Defined in [account.ts:67](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L67)* +*Defined in [account.ts:71](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L71)* **Parameters:** @@ -260,7 +260,7 @@ ___ ▸ **retryTxResult**(txHash: *`Uint8Array`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:73](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L73)* +*Defined in [account.ts:77](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L77)* **Parameters:** @@ -277,7 +277,7 @@ ___ ▸ **sendMoney**(receiverId: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:129](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L129)* +*Defined in [account.ts:136](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L136)* **Parameters:** @@ -295,7 +295,7 @@ ___ ▸ **signAndSendTransaction**(receiverId: *`string`*, actions: *[Action](_transaction_.action.md)[]*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:88](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L88)* +*Defined in [account.ts:92](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L92)* **Parameters:** @@ -311,15 +311,15 @@ ___ ## stake -▸ **stake**(publicKey: *`string`*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> +▸ **stake**(publicKey: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*, amount: *`BN`*): `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> -*Defined in [account.ts:164](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L164)* +*Defined in [account.ts:171](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L171)* **Parameters:** | Name | Type | | ------ | ------ | -| publicKey | `string` | +| publicKey | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | | amount | `BN` | **Returns:** `Promise`<[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)> @@ -331,7 +331,7 @@ ___ ▸ **state**(): `Promise`<[AccountState](../interfaces/_account_.accountstate.md)> -*Defined in [account.ts:62](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L62)* +*Defined in [account.ts:66](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L66)* **Returns:** `Promise`<[AccountState](../interfaces/_account_.accountstate.md)> @@ -342,7 +342,7 @@ ___ ▸ **viewFunction**(contractId: *`string`*, methodName: *`string`*, args: *`any`*): `Promise`<`any`> -*Defined in [account.ts:168](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L168)* +*Defined in [account.ts:175](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L175)* **Parameters:** diff --git a/docs/classes/_account_creator_.accountcreator.md b/docs/classes/_account_creator_.accountcreator.md index be51fee376..492068bab9 100644 --- a/docs/classes/_account_creator_.accountcreator.md +++ b/docs/classes/_account_creator_.accountcreator.md @@ -16,16 +16,16 @@ Account creator provides interface to specific implementation to acutally create ## `` createAccount -▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*): `Promise`<`void`> +▸ **createAccount**(newAccountId: *`string`*, publicKey: *[PublicKey](_utils_key_pair_.publickey.md)*): `Promise`<`void`> -*Defined in [account_creator.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L10)* +*Defined in [account_creator.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L11)* **Parameters:** | Name | Type | | ------ | ------ | | newAccountId | `string` | -| publicKey | `string` | +| publicKey | [PublicKey](_utils_key_pair_.publickey.md) | **Returns:** `Promise`<`void`> diff --git a/docs/classes/_account_creator_.localaccountcreator.md b/docs/classes/_account_creator_.localaccountcreator.md index a02e5ab01a..8b3124e569 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/b17214a/src.ts/account_creator.ts#L15)* +*Defined in [account_creator.ts:16](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L16)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● initialBalance**: *`BN`* -*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L15)* +*Defined in [account_creator.ts:16](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L16)* ___ @@ -44,7 +44,7 @@ ___ **● masterAccount**: *[Account](_account_.account.md)* -*Defined in [account_creator.ts:14](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L14)* +*Defined in [account_creator.ts:15](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L15)* ___ @@ -54,18 +54,18 @@ ___ ## createAccount -▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*): `Promise`<`void`> +▸ **createAccount**(newAccountId: *`string`*, publicKey: *[PublicKey](_utils_key_pair_.publickey.md)*): `Promise`<`void`> *Overrides [AccountCreator](_account_creator_.accountcreator.md).[createAccount](_account_creator_.accountcreator.md#createaccount)* -*Defined in [account_creator.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L23)* +*Defined in [account_creator.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L24)* **Parameters:** | Name | Type | | ------ | ------ | | newAccountId | `string` | -| publicKey | `string` | +| publicKey | [PublicKey](_utils_key_pair_.publickey.md) | **Returns:** `Promise`<`void`> diff --git a/docs/classes/_account_creator_.urlaccountcreator.md b/docs/classes/_account_creator_.urlaccountcreator.md index 9300bfebc9..14fb21baf5 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/b17214a/src.ts/account_creator.ts#L31)* +*Defined in [account_creator.ts:32](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L32)* **Parameters:** @@ -35,7 +35,7 @@ ___ **● connection**: *[Connection](_connection_.connection.md)* -*Defined in [account_creator.ts:30](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L30)* +*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L31)* ___ @@ -44,7 +44,7 @@ ___ **● helperConnection**: *[ConnectionInfo](../interfaces/_utils_web_.connectioninfo.md)* -*Defined in [account_creator.ts:31](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L31)* +*Defined in [account_creator.ts:32](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L32)* ___ @@ -54,18 +54,18 @@ ___ ## createAccount -▸ **createAccount**(newAccountId: *`string`*, publicKey: *`string`*): `Promise`<`void`> +▸ **createAccount**(newAccountId: *`string`*, publicKey: *[PublicKey](_utils_key_pair_.publickey.md)*): `Promise`<`void`> *Overrides [AccountCreator](_account_creator_.accountcreator.md).[createAccount](_account_creator_.accountcreator.md#createaccount)* -*Defined in [account_creator.ts:39](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account_creator.ts#L39)* +*Defined in [account_creator.ts:40](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account_creator.ts#L40)* **Parameters:** | Name | Type | | ------ | ------ | | newAccountId | `string` | -| publicKey | `string` | +| publicKey | [PublicKey](_utils_key_pair_.publickey.md) | **Returns:** `Promise`<`void`> diff --git a/docs/classes/_connection_.connection.md b/docs/classes/_connection_.connection.md index b1727c17b3..f805aada18 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/b17214a/src.ts/connection.ts#L25)* +*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/connection.ts#L25)* **Parameters:** @@ -34,7 +34,7 @@ ___ **● networkId**: *`string`* -*Defined in [connection.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/connection.ts#L23)* +*Defined in [connection.ts:23](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/connection.ts#L24)* +*Defined in [connection.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/connection.ts#L25)* +*Defined in [connection.ts:25](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/connection.ts#L33)* +*Defined in [connection.ts:33](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/connection.ts#L33)* **Parameters:** diff --git a/docs/classes/_contract_.contract.md b/docs/classes/_contract_.contract.md index a084685806..4a162a797e 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/b17214a/src.ts/contract.ts#L8)* +*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/contract.ts#L7)* +*Defined in [contract.ts:7](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/contract.ts#L7)* ___ @@ -48,7 +48,7 @@ ___ **● contractId**: *`string`* -*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/contract.ts#L8)* +*Defined in [contract.ts:8](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 bff7034e96..8dc198b9a4 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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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 473c6f58a1..1ead0c1d16 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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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 815df100ae..8a95c83c2a 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/b17214a/src.ts/key_stores/keystore.ts#L12)* +*Defined in [key_stores/keystore.ts:12](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/keystore.ts#L14)* +*Defined in [key_stores/keystore.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/keystore.ts#L10)* +*Defined in [key_stores/keystore.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/keystore.ts#L13)* +*Defined in [key_stores/keystore.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/keystore.ts#L11)* +*Defined in [key_stores/keystore.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/keystore.ts#L9)* +*Defined in [key_stores/keystore.ts:9](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 4e627cd1c0..5a1d70ebb5 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/b17214a/src.ts/key_stores/merge_key_store.ts#L10)* +*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L10)* +*Defined in [key_stores/merge_key_store.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L40)* +*Defined in [key_stores/merge_key_store.ts:40](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L56)* +*Defined in [key_stores/merge_key_store.ts:56](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L24)* +*Defined in [key_stores/merge_key_store.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L46)* +*Defined in [key_stores/merge_key_store.ts:46](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L34)* +*Defined in [key_stores/merge_key_store.ts:34](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/key_stores/merge_key_store.ts#L20)* +*Defined in [key_stores/merge_key_store.ts:20](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 cf0766ba2d..f887873b19 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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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 7e55b91db8..c85f12f0d8 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/b17214a/src.ts/near.ts#L14)* +*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/near.ts#L14)* +*Defined in [near.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L14)* ___ @@ -41,7 +41,7 @@ ___ **● config**: *`any`* -*Defined in [near.ts:12](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/near.ts#L12)* +*Defined in [near.ts:12](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/near.ts#L13)* +*Defined in [near.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/near.ts#L33)* +*Defined in [near.ts:33](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L33)* **Parameters:** @@ -77,39 +77,19 @@ ___ ## createAccount -▸ **createAccount**(accountId: *`string`*, publicKey: *`string`*): `Promise`<[Account](_account_.account.md)> +▸ **createAccount**(accountId: *`string`*, publicKey: *[PublicKey](_utils_key_pair_.publickey.md)*): `Promise`<[Account](_account_.account.md)> -*Defined in [near.ts:39](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/near.ts#L39)* +*Defined in [near.ts:39](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L39)* **Parameters:** | Name | Type | | ------ | ------ | | accountId | `string` | -| publicKey | `string` | +| publicKey | [PublicKey](_utils_key_pair_.publickey.md) | **Returns:** `Promise`<[Account](_account_.account.md)> -___ - - -## deployContract - -▸ **deployContract**(contractId: *`string`*, wasmByteArray: *`Uint8Array`*): `Promise`<`string`> - -*Defined in [near.ts:63](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/near.ts#L63)* - -Backwards compatibility method. Use `contractAccount.deployContract` or `yourAccount.createAndDeployContract` instead. - -**Parameters:** - -| Name | Type | Description | -| ------ | ------ | ------ | -| contractId | `string` | \- | -| wasmByteArray | `Uint8Array` | | - -**Returns:** `Promise`<`string`> - ___ @@ -117,7 +97,7 @@ ___ ▸ **loadContract**(contractId: *`string`*, options: *`object`*): `Promise`<[Contract](_contract_.contract.md)> -*Defined in [near.ts:52](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/near.ts#L52)* +*Defined in [near.ts:52](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L52)* Backwards compatibility method. Use `new nearlib.Contract(yourAccount, contractId, { viewMethods, changeMethods })` instead. @@ -142,7 +122,7 @@ ___ ▸ **sendTokens**(amount: *`BN`*, originator: *`string`*, receiver: *`string`*): `Promise`<`string`> -*Defined in [near.ts:76](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/near.ts#L76)* +*Defined in [near.ts:64](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L64)* 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 45b69653ec..ac795b8972 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/b17214a/src.ts/providers/json-rpc-provider.ts#L13)* +*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L13)* +*Defined in [providers/json-rpc-provider.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L50)* +*Defined in [providers/json-rpc-provider.ts:50](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L22)* +*Defined in [providers/json-rpc-provider.ts:22](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L42)* +*Defined in [providers/json-rpc-provider.ts:42](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L54)* +*Defined in [providers/json-rpc-provider.ts:54](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/json-rpc-provider.ts#L54)* **Parameters:** @@ -119,7 +119,7 @@ ___ *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/b17214a/src.ts/providers/json-rpc-provider.ts#L33)* +*Defined in [providers/json-rpc-provider.ts:33](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/json-rpc-provider.ts#L33)* **Parameters:** @@ -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/b17214a/src.ts/providers/json-rpc-provider.ts#L29)* +*Defined in [providers/json-rpc-provider.ts:29](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/json-rpc-provider.ts#L38)* +*Defined in [providers/json-rpc-provider.ts:38](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 997fbc2e74..58bc6e1d70 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/b17214a/src.ts/providers/provider.ts#L75)* +*Defined in [providers/provider.ts:80](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L80)* **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/b17214a/src.ts/providers/provider.ts#L69)* +*Defined in [providers/provider.ts:74](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L74)* **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/b17214a/src.ts/providers/provider.ts#L74)* +*Defined in [providers/provider.ts:79](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L79)* **Parameters:** @@ -60,7 +60,7 @@ ___ ▸ **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/b17214a/src.ts/providers/provider.ts#L72)* +*Defined in [providers/provider.ts:77](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L77)* **Parameters:** @@ -77,7 +77,7 @@ ___ ▸ **status**(): `Promise`<[NodeStatusResult](../interfaces/_providers_provider_.nodestatusresult.md)> -*Defined in [providers/provider.ts:70](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L70)* +*Defined in [providers/provider.ts:75](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L75)* **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/b17214a/src.ts/providers/provider.ts#L73)* +*Defined in [providers/provider.ts:78](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L78)* **Parameters:** diff --git a/docs/classes/_signer_.inmemorysigner.md b/docs/classes/_signer_.inmemorysigner.md index b10187ced7..5923ba15b2 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/b17214a/src.ts/signer.ts#L47)* +*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/signer.ts#L47)* +*Defined in [signer.ts:47](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/signer.ts#L47)* ___ @@ -46,11 +46,11 @@ ___ ## createKey -▸ **createKey**(accountId: *`string`*, networkId: *`string`*): `Promise`<`string`> +▸ **createKey**(accountId: *`string`*, networkId: *`string`*): `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> *Overrides [Signer](_signer_.signer.md).[createKey](_signer_.signer.md#createkey)* -*Defined in [signer.ts:54](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/signer.ts#L54)* +*Defined in [signer.ts:54](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/signer.ts#L54)* **Parameters:** @@ -59,18 +59,18 @@ ___ | accountId | `string` | | networkId | `string` | -**Returns:** `Promise`<`string`> +**Returns:** `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> ___ ## getPublicKey -▸ **getPublicKey**(accountId?: *`string`*, networkId?: *`string`*): `Promise`<`string`> +▸ **getPublicKey**(accountId?: *`string`*, networkId?: *`string`*): `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> *Overrides [Signer](_signer_.signer.md).[getPublicKey](_signer_.signer.md#getpublickey)* -*Defined in [signer.ts:60](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/signer.ts#L60)* +*Defined in [signer.ts:60](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/signer.ts#L60)* **Parameters:** @@ -79,7 +79,7 @@ ___ | `Optional` accountId | `string` | | `Optional` networkId | `string` | -**Returns:** `Promise`<`string`> +**Returns:** `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> ___ @@ -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/b17214a/src.ts/signer.ts#L65)* +*Defined in [signer.ts:65](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/signer.ts#L38)* +*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 f93bccb796..1e7e4436d5 100644 --- a/docs/classes/_signer_.signer.md +++ b/docs/classes/_signer_.signer.md @@ -14,9 +14,9 @@ General signing interface, can be used for in memory signing, RPC singing, exter ## `` createKey -▸ **createKey**(accountId: *`string`*, networkId?: *`string`*): `Promise`<`string`> +▸ **createKey**(accountId: *`string`*, networkId?: *`string`*): `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> -*Defined in [signer.ts:15](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/signer.ts#L15)* +*Defined in [signer.ts:15](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/signer.ts#L15)* Creates new key and returns public key. @@ -27,16 +27,16 @@ Creates new key and returns public key. | accountId | `string` | | `Optional` networkId | `string` | -**Returns:** `Promise`<`string`> +**Returns:** `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> ___ ## `` getPublicKey -▸ **getPublicKey**(accountId?: *`string`*, networkId?: *`string`*): `Promise`<`string`> +▸ **getPublicKey**(accountId?: *`string`*, networkId?: *`string`*): `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> -*Defined in [signer.ts:22](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/signer.ts#L22)* +*Defined in [signer.ts:22](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/signer.ts#L22)* Returns public key for given account / network. @@ -47,7 +47,7 @@ Returns public key for given account / network. | `Optional` accountId | `string` | accountId to retrieve from. | | `Optional` networkId | `string` | network for this accountId. | -**Returns:** `Promise`<`string`> +**Returns:** `Promise`<[PublicKey](_utils_key_pair_.publickey.md)> ___ @@ -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/b17214a/src.ts/signer.ts#L30)* +*Defined in [signer.ts:30](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/signer.ts#L38)* +*Defined in [signer.ts:38](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 index aa8e86ba74..74c40355f6 100644 --- a/docs/classes/_transaction_.accesskey.md +++ b/docs/classes/_transaction_.accesskey.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● nonce**: *`number`* -*Defined in [transaction.ts:45](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L45)* +*Defined in [transaction.ts:46](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L46)* ___ @@ -45,7 +45,7 @@ ___ **● permission**: *[AccessKeyPermission](_transaction_.accesskeypermission.md)* -*Defined in [transaction.ts:46](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L46)* +*Defined in [transaction.ts:47](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L47)* ___ diff --git a/docs/classes/_transaction_.accesskeypermission.md b/docs/classes/_transaction_.accesskeypermission.md index 3cf6dbeb05..9f143529e1 100644 --- a/docs/classes/_transaction_.accesskeypermission.md +++ b/docs/classes/_transaction_.accesskeypermission.md @@ -16,7 +16,7 @@ *Inherited from [Enum](_transaction_.enum.md).[constructor](_transaction_.enum.md#constructor)* -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* **Parameters:** @@ -38,7 +38,7 @@ ___ *Inherited from [Enum](_transaction_.enum.md).[enum](_transaction_.enum.md#enum)* -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* ___ @@ -47,7 +47,7 @@ ___ **● fullAccess**: *[FullAccessPermission](_transaction_.fullaccesspermission.md)* -*Defined in [transaction.ts:41](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L41)* +*Defined in [transaction.ts:42](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L42)* ___ @@ -56,7 +56,7 @@ ___ **● functionCall**: *[FunctionCallPermission](_transaction_.functioncallpermission.md)* -*Defined in [transaction.ts:40](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L40)* +*Defined in [transaction.ts:41](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L41)* ___ diff --git a/docs/classes/_transaction_.action.md b/docs/classes/_transaction_.action.md index 8756df394c..49ecacfcc1 100644 --- a/docs/classes/_transaction_.action.md +++ b/docs/classes/_transaction_.action.md @@ -16,7 +16,7 @@ *Inherited from [Enum](_transaction_.enum.md).[constructor](_transaction_.enum.md#constructor)* -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● addKey**: *[AddKey](_transaction_.addkey.md)* -*Defined in [transaction.ts:147](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L147)* +*Defined in [transaction.ts:135](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L135)* ___ @@ -45,7 +45,7 @@ ___ **● createAccount**: *[CreateAccount](_transaction_.createaccount.md)* -*Defined in [transaction.ts:142](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L142)* +*Defined in [transaction.ts:130](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L130)* ___ @@ -54,7 +54,7 @@ ___ **● deleteAccount**: *[DeleteAccount](_transaction_.deleteaccount.md)* -*Defined in [transaction.ts:149](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L149)* +*Defined in [transaction.ts:137](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L137)* ___ @@ -63,7 +63,7 @@ ___ **● deleteKey**: *[DeleteKey](_transaction_.deletekey.md)* -*Defined in [transaction.ts:148](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L148)* +*Defined in [transaction.ts:136](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L136)* ___ @@ -72,7 +72,7 @@ ___ **● deployContract**: *[DeployContract](_transaction_.deploycontract.md)* -*Defined in [transaction.ts:143](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L143)* +*Defined in [transaction.ts:131](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L131)* ___ @@ -83,7 +83,7 @@ ___ *Inherited from [Enum](_transaction_.enum.md).[enum](_transaction_.enum.md#enum)* -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* ___ @@ -92,7 +92,7 @@ ___ **● functionCall**: *[FunctionCall](_transaction_.functioncall.md)* -*Defined in [transaction.ts:144](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L144)* +*Defined in [transaction.ts:132](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L132)* ___ @@ -101,7 +101,7 @@ ___ **● stake**: *[Stake](_transaction_.stake.md)* -*Defined in [transaction.ts:146](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L146)* +*Defined in [transaction.ts:134](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L134)* ___ @@ -110,7 +110,7 @@ ___ **● transfer**: *[Transfer](_transaction_.transfer.md)* -*Defined in [transaction.ts:145](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L145)* +*Defined in [transaction.ts:133](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L133)* ___ diff --git a/docs/classes/_transaction_.addkey.md b/docs/classes/_transaction_.addkey.md index ad50ae6927..9b3629d0d3 100644 --- a/docs/classes/_transaction_.addkey.md +++ b/docs/classes/_transaction_.addkey.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,16 +36,16 @@ ___ **● accessKey**: *[AccessKey](_transaction_.accesskey.md)* -*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L64)* +*Defined in [transaction.ts:65](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L65)* ___ ## publicKey -**● publicKey**: *[PublicKey](_transaction_.publickey.md)* +**● publicKey**: *[PublicKey](_utils_key_pair_.publickey.md)* -*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L64)* +*Defined in [transaction.ts:65](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L65)* ___ diff --git a/docs/classes/_transaction_.assignable.md b/docs/classes/_transaction_.assignable.md index 6fcc230ff7..926c28ba5c 100644 --- a/docs/classes/_transaction_.assignable.md +++ b/docs/classes/_transaction_.assignable.md @@ -24,7 +24,7 @@ ⊕ **new Assignable**(properties: *`any`*): [Assignable](_transaction_.assignable.md) -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** diff --git a/docs/classes/_transaction_.createaccount.md b/docs/classes/_transaction_.createaccount.md index e212a0891a..a30dd860b0 100644 --- a/docs/classes/_transaction_.createaccount.md +++ b/docs/classes/_transaction_.createaccount.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** diff --git a/docs/classes/_transaction_.deleteaccount.md b/docs/classes/_transaction_.deleteaccount.md index e623d956dd..2634d7ed79 100644 --- a/docs/classes/_transaction_.deleteaccount.md +++ b/docs/classes/_transaction_.deleteaccount.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● beneficiaryId**: *`string`* -*Defined in [transaction.ts:66](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L66)* +*Defined in [transaction.ts:67](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L67)* ___ diff --git a/docs/classes/_transaction_.deletekey.md b/docs/classes/_transaction_.deletekey.md index 390ef2ae3b..b41a0262b8 100644 --- a/docs/classes/_transaction_.deletekey.md +++ b/docs/classes/_transaction_.deletekey.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -34,9 +34,9 @@ ___ ## publicKey -**● publicKey**: *[PublicKey](_transaction_.publickey.md)* +**● publicKey**: *[PublicKey](_utils_key_pair_.publickey.md)* -*Defined in [transaction.ts:65](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L65)* +*Defined in [transaction.ts:66](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L66)* ___ diff --git a/docs/classes/_transaction_.deploycontract.md b/docs/classes/_transaction_.deploycontract.md index 7fa78953b5..3437b1f033 100644 --- a/docs/classes/_transaction_.deploycontract.md +++ b/docs/classes/_transaction_.deploycontract.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● code**: *`Uint8Array`* -*Defined in [transaction.ts:60](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L60)* +*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L61)* ___ diff --git a/docs/classes/_transaction_.enum.md b/docs/classes/_transaction_.enum.md index 2ead116bf5..69085f096e 100644 --- a/docs/classes/_transaction_.enum.md +++ b/docs/classes/_transaction_.enum.md @@ -16,7 +16,7 @@ ⊕ **new Enum**(properties: *`any`*): [Enum](_transaction_.enum.md) -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● enum**: *`string`* -*Defined in [transaction.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L10)* +*Defined in [transaction.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L11)* ___ diff --git a/docs/classes/_transaction_.fullaccesspermission.md b/docs/classes/_transaction_.fullaccesspermission.md index df0c7b562c..6aa71b2611 100644 --- a/docs/classes/_transaction_.fullaccesspermission.md +++ b/docs/classes/_transaction_.fullaccesspermission.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** diff --git a/docs/classes/_transaction_.functioncall.md b/docs/classes/_transaction_.functioncall.md index dec504b722..61e79cea68 100644 --- a/docs/classes/_transaction_.functioncall.md +++ b/docs/classes/_transaction_.functioncall.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● args**: *`Uint8Array`* -*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L61)* +*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L62)* ___ @@ -45,7 +45,7 @@ ___ **● deposit**: *`BN`* -*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L61)* +*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L62)* ___ @@ -54,7 +54,7 @@ ___ **● gas**: *`BN`* -*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L61)* +*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L62)* ___ @@ -63,7 +63,7 @@ ___ **● methodName**: *`string`* -*Defined in [transaction.ts:61](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L61)* +*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L62)* ___ diff --git a/docs/classes/_transaction_.functioncallpermission.md b/docs/classes/_transaction_.functioncallpermission.md index 7d05042488..478c3c4bfb 100644 --- a/docs/classes/_transaction_.functioncallpermission.md +++ b/docs/classes/_transaction_.functioncallpermission.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● allowance**: *`BN`* -*Defined in [transaction.ts:32](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L32)* +*Defined in [transaction.ts:33](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L33)* ___ @@ -45,7 +45,7 @@ ___ **● methodNames**: *`String`[]* -*Defined in [transaction.ts:34](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L34)* +*Defined in [transaction.ts:35](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L35)* ___ @@ -54,7 +54,7 @@ ___ **● receiverId**: *`string`* -*Defined in [transaction.ts:33](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L33)* +*Defined in [transaction.ts:34](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L34)* ___ diff --git a/docs/classes/_transaction_.iaction.md b/docs/classes/_transaction_.iaction.md index f0ace38cb9..8aefc3a02e 100644 --- a/docs/classes/_transaction_.iaction.md +++ b/docs/classes/_transaction_.iaction.md @@ -32,7 +32,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** diff --git a/docs/classes/_transaction_.publickey.md b/docs/classes/_transaction_.publickey.md deleted file mode 100644 index 598f056441..0000000000 --- a/docs/classes/_transaction_.publickey.md +++ /dev/null @@ -1,47 +0,0 @@ - - -# Hierarchy - -**PublicKey** - -# Constructors - - - -## constructor - -⊕ **new PublicKey**(publicKey: *`string`*): [PublicKey](_transaction_.publickey.md) - -*Defined in [transaction.ts:106](https://github.com/nearprotocol/nearlib/blob/b17214a/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/b17214a/src.ts/transaction.ts#L106)* - -___ - - -## keyType - -**● keyType**: *[KeyType](../enums/_transaction_.keytype.md)* - -*Defined in [transaction.ts:105](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L105)* - -___ - diff --git a/docs/classes/_transaction_.signature.md b/docs/classes/_transaction_.signature.md index 067895422d..33afdee5d1 100644 --- a/docs/classes/_transaction_.signature.md +++ b/docs/classes/_transaction_.signature.md @@ -12,7 +12,7 @@ ⊕ **new Signature**(signature: *`Uint8Array`*): [Signature](_transaction_.signature.md) -*Defined in [transaction.ts:116](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L116)* +*Defined in [transaction.ts:103](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L103)* **Parameters:** @@ -32,16 +32,16 @@ ___ **● data**: *`Uint8Array`* -*Defined in [transaction.ts:116](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L116)* +*Defined in [transaction.ts:103](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L103)* ___ ## keyType -**● keyType**: *[KeyType](../enums/_transaction_.keytype.md)* +**● keyType**: *[KeyType](../enums/_utils_key_pair_.keytype.md)* -*Defined in [transaction.ts:115](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L115)* +*Defined in [transaction.ts:102](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L102)* ___ diff --git a/docs/classes/_transaction_.signedtransaction.md b/docs/classes/_transaction_.signedtransaction.md index 75f5b41000..27eff95f22 100644 --- a/docs/classes/_transaction_.signedtransaction.md +++ b/docs/classes/_transaction_.signedtransaction.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● signature**: *[Signature](_transaction_.signature.md)* -*Defined in [transaction.ts:134](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L134)* +*Defined in [transaction.ts:122](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L122)* ___ @@ -45,7 +45,7 @@ ___ **● transaction**: *[Transaction](_transaction_.transaction.md)* -*Defined in [transaction.ts:133](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L133)* +*Defined in [transaction.ts:121](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L121)* ___ @@ -57,7 +57,7 @@ ___ ▸ **encode**(): `Uint8Array` -*Defined in [transaction.ts:136](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L136)* +*Defined in [transaction.ts:124](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L124)* **Returns:** `Uint8Array` diff --git a/docs/classes/_transaction_.stake.md b/docs/classes/_transaction_.stake.md index 2d345ca586..280aaddcac 100644 --- a/docs/classes/_transaction_.stake.md +++ b/docs/classes/_transaction_.stake.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -34,9 +34,9 @@ ___ ## publicKey -**● publicKey**: *[PublicKey](_transaction_.publickey.md)* +**● publicKey**: *[PublicKey](_utils_key_pair_.publickey.md)* -*Defined in [transaction.ts:63](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L63)* +*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L64)* ___ @@ -45,7 +45,7 @@ ___ **● stake**: *`BN`* -*Defined in [transaction.ts:63](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L63)* +*Defined in [transaction.ts:64](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L64)* ___ diff --git a/docs/classes/_transaction_.transaction.md b/docs/classes/_transaction_.transaction.md index 50d0f5ddde..8603700a1d 100644 --- a/docs/classes/_transaction_.transaction.md +++ b/docs/classes/_transaction_.transaction.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,16 @@ ___ **● actions**: *[Action](_transaction_.action.md)[]* -*Defined in [transaction.ts:129](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L129)* +*Defined in [transaction.ts:116](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L116)* + +___ + + +## blockHash + +**● blockHash**: *`Uint8Array`* + +*Defined in [transaction.ts:117](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L117)* ___ @@ -45,16 +54,16 @@ ___ **● nonce**: *`number`* -*Defined in [transaction.ts:127](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L127)* +*Defined in [transaction.ts:114](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L114)* ___ ## publicKey -**● publicKey**: *[PublicKey](_transaction_.publickey.md)* +**● publicKey**: *[PublicKey](_utils_key_pair_.publickey.md)* -*Defined in [transaction.ts:126](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L126)* +*Defined in [transaction.ts:113](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L113)* ___ @@ -63,7 +72,7 @@ ___ **● receiverId**: *`string`* -*Defined in [transaction.ts:128](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L128)* +*Defined in [transaction.ts:115](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L115)* ___ @@ -72,7 +81,7 @@ ___ **● signerId**: *`string`* -*Defined in [transaction.ts:125](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L125)* +*Defined in [transaction.ts:112](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L112)* ___ diff --git a/docs/classes/_transaction_.transfer.md b/docs/classes/_transaction_.transfer.md index 0917c26bb9..04e02b765b 100644 --- a/docs/classes/_transaction_.transfer.md +++ b/docs/classes/_transaction_.transfer.md @@ -16,7 +16,7 @@ *Inherited from [Assignable](_transaction_.assignable.md).[constructor](_transaction_.assignable.md#constructor)* -*Defined in [transaction.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L23)* +*Defined in [transaction.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L24)* **Parameters:** @@ -36,7 +36,7 @@ ___ **● deposit**: *`BN`* -*Defined in [transaction.ts:62](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L62)* +*Defined in [transaction.ts:63](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L63)* ___ diff --git a/docs/classes/_utils_key_pair_.keypair.md b/docs/classes/_utils_key_pair_.keypair.md index 6724e0602b..100f738ae9 100644 --- a/docs/classes/_utils_key_pair_.keypair.md +++ b/docs/classes/_utils_key_pair_.keypair.md @@ -12,11 +12,11 @@ ## `` getPublicKey -▸ **getPublicKey**(): `string` +▸ **getPublicKey**(): [PublicKey](_utils_key_pair_.publickey.md) -*Defined in [utils/key_pair.ts:17](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L17)* +*Defined in [utils/key_pair.ts:71](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L71)* -**Returns:** `string` +**Returns:** [PublicKey](_utils_key_pair_.publickey.md) ___ @@ -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/b17214a/src.ts/utils/key_pair.ts#L14)* +*Defined in [utils/key_pair.ts:68](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L68)* **Parameters:** @@ -42,7 +42,7 @@ ___ ▸ **toString**(): `string` -*Defined in [utils/key_pair.ts:16](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L16)* +*Defined in [utils/key_pair.ts:70](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L70)* **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/b17214a/src.ts/utils/key_pair.ts#L15)* +*Defined in [utils/key_pair.ts:69](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L69)* **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/b17214a/src.ts/utils/key_pair.ts#L19)* +*Defined in [utils/key_pair.ts:73](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L73)* **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/b17214a/src.ts/utils/key_pair.ts#L26)* +*Defined in [utils/key_pair.ts:80](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L80)* **Parameters:** diff --git a/docs/classes/_utils_key_pair_.keypaired25519.md b/docs/classes/_utils_key_pair_.keypaired25519.md index 5a723b00a3..36f503f05d 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/b17214a/src.ts/utils/key_pair.ts#L44)* +*Defined in [utils/key_pair.ts:101](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L101)* Construct an instance of key pair given a secret key. It's generally assumed that these are encoded in base58. @@ -36,9 +36,9 @@ ___ ## publicKey -**● publicKey**: *`string`* +**● publicKey**: *[PublicKey](_utils_key_pair_.publickey.md)* -*Defined in [utils/key_pair.ts:43](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L43)* +*Defined in [utils/key_pair.ts:100](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L100)* ___ @@ -47,7 +47,7 @@ ___ **● secretKey**: *`string`* -*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L44)* +*Defined in [utils/key_pair.ts:101](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L101)* ___ @@ -57,13 +57,13 @@ ___ ## getPublicKey -▸ **getPublicKey**(): `string` +▸ **getPublicKey**(): [PublicKey](_utils_key_pair_.publickey.md) *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/b17214a/src.ts/utils/key_pair.ts#L86)* +*Defined in [utils/key_pair.ts:143](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L143)* -**Returns:** `string` +**Returns:** [PublicKey](_utils_key_pair_.publickey.md) ___ @@ -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/b17214a/src.ts/utils/key_pair.ts#L73)* +*Defined in [utils/key_pair.ts:130](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L130)* **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/b17214a/src.ts/utils/key_pair.ts#L82)* +*Defined in [utils/key_pair.ts:139](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L139)* **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/b17214a/src.ts/utils/key_pair.ts#L78)* +*Defined in [utils/key_pair.ts:135](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L135)* **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/b17214a/src.ts/utils/key_pair.ts#L68)* +*Defined in [utils/key_pair.ts:125](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L125)* 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/b17214a/src.ts/utils/key_pair.ts#L26)* +*Defined in [utils/key_pair.ts:80](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L80)* **Parameters:** diff --git a/docs/classes/_utils_key_pair_.publickey.md b/docs/classes/_utils_key_pair_.publickey.md new file mode 100644 index 0000000000..d8f3ed30eb --- /dev/null +++ b/docs/classes/_utils_key_pair_.publickey.md @@ -0,0 +1,98 @@ + + +PublicKey representation that has type and bytes of the key. + +# Hierarchy + +**PublicKey** + +# Constructors + + + +## constructor + +⊕ **new PublicKey**(keyType: *[KeyType](../enums/_utils_key_pair_.keytype.md)*, data: *`Uint8Array`*): [PublicKey](_utils_key_pair_.publickey.md) + +*Defined in [utils/key_pair.ts:37](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L37)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| keyType | [KeyType](../enums/_utils_key_pair_.keytype.md) | +| data | `Uint8Array` | + +**Returns:** [PublicKey](_utils_key_pair_.publickey.md) + +___ + +# Properties + + + +## data + +**● data**: *`Uint8Array`* + +*Defined in [utils/key_pair.ts:37](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L37)* + +___ + + +## keyType + +**● keyType**: *[KeyType](../enums/_utils_key_pair_.keytype.md)* + +*Defined in [utils/key_pair.ts:36](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L36)* + +___ + +# Methods + + + +## toString + +▸ **toString**(): `string` + +*Defined in [utils/key_pair.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L62)* + +**Returns:** `string` + +___ + + +## `` from + +▸ **from**(value: *`string` \| [PublicKey](_utils_key_pair_.publickey.md)*): [PublicKey](_utils_key_pair_.publickey.md) + +*Defined in [utils/key_pair.ts:44](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L44)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| value | `string` \| [PublicKey](_utils_key_pair_.publickey.md) | + +**Returns:** [PublicKey](_utils_key_pair_.publickey.md) + +___ + + +## `` fromString + +▸ **fromString**(encodedKey: *`string`*): [PublicKey](_utils_key_pair_.publickey.md) + +*Defined in [utils/key_pair.ts:51](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L51)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| encodedKey | `string` | + +**Returns:** [PublicKey](_utils_key_pair_.publickey.md) + +___ + diff --git a/docs/classes/_utils_serialize_.binaryreader.md b/docs/classes/_utils_serialize_.binaryreader.md index 68d8477b08..e435c5e910 100644 --- a/docs/classes/_utils_serialize_.binaryreader.md +++ b/docs/classes/_utils_serialize_.binaryreader.md @@ -12,7 +12,7 @@ ⊕ **new BinaryReader**(buf: *`Buffer`*): [BinaryReader](_utils_serialize_.binaryreader.md) -*Defined in [utils/serialize.ts:92](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L92)* +*Defined in [utils/serialize.ts:92](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L92)* **Parameters:** @@ -32,7 +32,7 @@ ___ **● buf**: *`Buffer`* -*Defined in [utils/serialize.ts:91](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L91)* +*Defined in [utils/serialize.ts:91](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L91)* ___ @@ -41,7 +41,7 @@ ___ **● offset**: *`number`* -*Defined in [utils/serialize.ts:92](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L92)* +*Defined in [utils/serialize.ts:92](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L92)* ___ @@ -53,7 +53,7 @@ ___ ▸ **read_array**(fn: *`any`*): `any`[] -*Defined in [utils/serialize.ts:137](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L137)* +*Defined in [utils/serialize.ts:137](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L137)* **Parameters:** @@ -70,7 +70,7 @@ ___ ▸ **read_buffer**(len: *`number`*): `Buffer` -*Defined in [utils/serialize.ts:122](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L122)* +*Defined in [utils/serialize.ts:122](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L122)* **Parameters:** @@ -87,7 +87,7 @@ ___ ▸ **read_fixed_array**(len: *`number`*): `Uint8Array` -*Defined in [utils/serialize.ts:133](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L133)* +*Defined in [utils/serialize.ts:133](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L133)* **Parameters:** @@ -104,7 +104,7 @@ ___ ▸ **read_string**(): `string` -*Defined in [utils/serialize.ts:128](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L128)* +*Defined in [utils/serialize.ts:128](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L128)* **Returns:** `string` @@ -115,7 +115,7 @@ ___ ▸ **read_u128**(): `BN` -*Defined in [utils/serialize.ts:117](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L117)* +*Defined in [utils/serialize.ts:117](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L117)* **Returns:** `BN` @@ -126,7 +126,7 @@ ___ ▸ **read_u32**(): `number` -*Defined in [utils/serialize.ts:105](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L105)* +*Defined in [utils/serialize.ts:105](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L105)* **Returns:** `number` @@ -137,7 +137,7 @@ ___ ▸ **read_u64**(): `BN` -*Defined in [utils/serialize.ts:111](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L111)* +*Defined in [utils/serialize.ts:111](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L111)* **Returns:** `BN` @@ -148,7 +148,7 @@ ___ ▸ **read_u8**(): `number` -*Defined in [utils/serialize.ts:99](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L99)* +*Defined in [utils/serialize.ts:99](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L99)* **Returns:** `number` diff --git a/docs/classes/_utils_serialize_.binarywriter.md b/docs/classes/_utils_serialize_.binarywriter.md index b8b745316a..bc0d6fbd0e 100644 --- a/docs/classes/_utils_serialize_.binarywriter.md +++ b/docs/classes/_utils_serialize_.binarywriter.md @@ -12,7 +12,7 @@ ⊕ **new BinaryWriter**(): [BinaryWriter](_utils_serialize_.binarywriter.md) -*Defined in [utils/serialize.ts:24](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L24)* +*Defined in [utils/serialize.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L24)* **Returns:** [BinaryWriter](_utils_serialize_.binarywriter.md) @@ -26,7 +26,7 @@ ___ **● buf**: *`Buffer`* -*Defined in [utils/serialize.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L23)* +*Defined in [utils/serialize.ts:23](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L23)* ___ @@ -35,7 +35,7 @@ ___ **● length**: *`number`* -*Defined in [utils/serialize.ts:24](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L24)* +*Defined in [utils/serialize.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L24)* ___ @@ -47,7 +47,7 @@ ___ ▸ **maybe_resize**(): `void` -*Defined in [utils/serialize.ts:31](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L31)* +*Defined in [utils/serialize.ts:31](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L31)* **Returns:** `void` @@ -58,7 +58,7 @@ ___ ▸ **toArray**(): `Uint8Array` -*Defined in [utils/serialize.ts:85](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L85)* +*Defined in [utils/serialize.ts:85](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L85)* **Returns:** `Uint8Array` @@ -69,7 +69,7 @@ ___ ▸ **write_array**(array: *`any`[]*, fn: *`any`*): `void` -*Defined in [utils/serialize.ts:76](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L76)* +*Defined in [utils/serialize.ts:76](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L76)* **Parameters:** @@ -87,7 +87,7 @@ ___ ▸ **write_buffer**(buffer: *`Buffer`*): `void` -*Defined in [utils/serialize.ts:59](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L59)* +*Defined in [utils/serialize.ts:59](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L59)* **Parameters:** @@ -104,7 +104,7 @@ ___ ▸ **write_fixed_array**(array: *`Uint8Array`*): `void` -*Defined in [utils/serialize.ts:72](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L72)* +*Defined in [utils/serialize.ts:72](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L72)* **Parameters:** @@ -121,7 +121,7 @@ ___ ▸ **write_string**(str: *`string`*): `void` -*Defined in [utils/serialize.ts:65](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L65)* +*Defined in [utils/serialize.ts:65](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L65)* **Parameters:** @@ -138,7 +138,7 @@ ___ ▸ **write_u128**(value: *`BN`*): `void` -*Defined in [utils/serialize.ts:54](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L54)* +*Defined in [utils/serialize.ts:54](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L54)* **Parameters:** @@ -155,7 +155,7 @@ ___ ▸ **write_u32**(value: *`number`*): `void` -*Defined in [utils/serialize.ts:43](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L43)* +*Defined in [utils/serialize.ts:43](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L43)* **Parameters:** @@ -172,7 +172,7 @@ ___ ▸ **write_u64**(value: *`BN`*): `void` -*Defined in [utils/serialize.ts:49](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L49)* +*Defined in [utils/serialize.ts:49](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L49)* **Parameters:** @@ -189,7 +189,7 @@ ___ ▸ **write_u8**(value: *`number`*): `void` -*Defined in [utils/serialize.ts:37](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L37)* +*Defined in [utils/serialize.ts:37](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L37)* **Parameters:** diff --git a/docs/classes/_wallet_account_.walletaccount.md b/docs/classes/_wallet_account_.walletaccount.md index 1d5a8171f2..bc34613428 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/b17214a/src.ts/wallet-account.ts#L18)* +*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L17)* +*Defined in [wallet-account.ts:17](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/wallet-account.ts#L17)* ___ @@ -42,7 +42,7 @@ ___ **● _authDataKey**: *`string`* -*Defined in [wallet-account.ts:15](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/wallet-account.ts#L15)* +*Defined in [wallet-account.ts:15](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L16)* +*Defined in [wallet-account.ts:16](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/wallet-account.ts#L16)* ___ @@ -60,7 +60,7 @@ ___ **● _networkId**: *`string`* -*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/wallet-account.ts#L18)* +*Defined in [wallet-account.ts:18](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/wallet-account.ts#L18)* ___ @@ -69,7 +69,7 @@ ___ **● _walletBaseUrl**: *`string`* -*Defined in [wallet-account.ts:14](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/wallet-account.ts#L14)* +*Defined in [wallet-account.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L84)* +*Defined in [wallet-account.ts:84](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L97)* +*Defined in [wallet-account.ts:97](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L46)* +*Defined in [wallet-account.ts:46](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L37)* +*Defined in [wallet-account.ts:37](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L63)* +*Defined in [wallet-account.ts:63](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L108)* +*Defined in [wallet-account.ts:108](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 ca74da071c..34c4154f57 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/b17214a/src.ts/providers/provider.ts#L25)* +*Defined in [providers/provider.ts:25](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L25)* ___ @@ -28,7 +28,7 @@ ___ **Failed**: = "Failed" -*Defined in [providers/provider.ts:24](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L24)* +*Defined in [providers/provider.ts:24](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L24)* ___ @@ -37,7 +37,7 @@ ___ **Started**: = "Started" -*Defined in [providers/provider.ts:23](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L23)* +*Defined in [providers/provider.ts:23](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L23)* ___ @@ -46,7 +46,7 @@ ___ **Unknown**: = "Unknown" -*Defined in [providers/provider.ts:22](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L22)* +*Defined in [providers/provider.ts:22](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L22)* ___ diff --git a/docs/enums/_transaction_.keytype.md b/docs/enums/_transaction_.keytype.md deleted file mode 100644 index fd07c24ecb..0000000000 --- a/docs/enums/_transaction_.keytype.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# Index - -### Enumeration members - -* [ED25519](_transaction_.keytype.md#ed25519) - ---- - -# Enumeration members - - - -## ED25519 - -**ED25519**: = 0 - -*Defined in [transaction.ts:101](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L101)* - -___ - diff --git a/docs/enums/_utils_key_pair_.keytype.md b/docs/enums/_utils_key_pair_.keytype.md new file mode 100644 index 0000000000..803b91b2ac --- /dev/null +++ b/docs/enums/_utils_key_pair_.keytype.md @@ -0,0 +1,24 @@ + + +All supported key types + +# Index + +### Enumeration members + +* [ED25519](_utils_key_pair_.keytype.md#ed25519) + +--- + +# Enumeration members + + + +## ED25519 + +**ED25519**: = 0 + +*Defined in [utils/key_pair.ts:15](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L15)* + +___ + diff --git a/docs/interfaces/_account_.accountstate.md b/docs/interfaces/_account_.accountstate.md index efa1aa8a93..a450729969 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/b17214a/src.ts/account.ts#L30)* +*Defined in [account.ts:31](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L31)* ___ @@ -21,7 +21,7 @@ ___ **● amount**: *`string`* -*Defined in [account.ts:31](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L31)* +*Defined in [account.ts:32](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L32)* ___ @@ -30,7 +30,7 @@ ___ **● code_hash**: *`string`* -*Defined in [account.ts:33](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L33)* +*Defined in [account.ts:34](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L34)* ___ @@ -39,7 +39,7 @@ ___ **● staked**: *`string`* -*Defined in [account.ts:32](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L32)* +*Defined in [account.ts:33](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L33)* ___ 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 5b03352ef1..2f79fb80d7 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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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 92a551e27e..3e86dfb093 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/b17214a/src.ts/providers/provider.ts#L45)* +*Defined in [providers/provider.ts:50](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L50)* ___ @@ -21,7 +21,7 @@ ___ **● approval_sigs**: *`string`* -*Defined in [providers/provider.ts:46](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L46)* +*Defined in [providers/provider.ts:51](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L51)* ___ @@ -30,7 +30,7 @@ ___ **● hash**: *`string`* -*Defined in [providers/provider.ts:47](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L47)* +*Defined in [providers/provider.ts:52](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L52)* ___ @@ -39,7 +39,7 @@ ___ **● height**: *`number`* -*Defined in [providers/provider.ts:48](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L48)* +*Defined in [providers/provider.ts:53](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L53)* ___ @@ -48,7 +48,7 @@ ___ **● prev_hash**: *`string`* -*Defined in [providers/provider.ts:49](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L49)* +*Defined in [providers/provider.ts:54](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L54)* ___ @@ -57,7 +57,7 @@ ___ **● prev_state_root**: *`string`* -*Defined in [providers/provider.ts:50](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L50)* +*Defined in [providers/provider.ts:55](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L55)* ___ @@ -66,7 +66,7 @@ ___ **● timestamp**: *`number`* -*Defined in [providers/provider.ts:51](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L51)* +*Defined in [providers/provider.ts:56](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L56)* ___ @@ -75,7 +75,7 @@ ___ **● total_weight**: *[TotalWeight](_providers_provider_.totalweight.md)* -*Defined in [providers/provider.ts:52](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L52)* +*Defined in [providers/provider.ts:57](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L57)* ___ @@ -84,7 +84,7 @@ ___ **● tx_root**: *`string`* -*Defined in [providers/provider.ts:53](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L53)* +*Defined in [providers/provider.ts:58](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L58)* ___ diff --git a/docs/interfaces/_providers_provider_.blockresult.md b/docs/interfaces/_providers_provider_.blockresult.md index d77ae8f8e1..11d9328b04 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/b17214a/src.ts/providers/provider.ts#L64)* +*Defined in [providers/provider.ts:69](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L69)* ___ @@ -21,7 +21,7 @@ ___ **● transactions**: *[Transaction](_providers_provider_.transaction.md)[]* -*Defined in [providers/provider.ts:65](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L65)* +*Defined in [providers/provider.ts:70](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L70)* ___ diff --git a/docs/interfaces/_providers_provider_.finaltransactionresult.md b/docs/interfaces/_providers_provider_.finaltransactionresult.md index 17e343c606..825d56c66e 100644 --- a/docs/interfaces/_providers_provider_.finaltransactionresult.md +++ b/docs/interfaces/_providers_provider_.finaltransactionresult.md @@ -6,22 +6,22 @@ # Properties - + -## logs +## status -**● logs**: *[TransactionLog](_providers_provider_.transactionlog.md)[]* +**● status**: *[FinalTransactionStatus](../enums/_providers_provider_.finaltransactionstatus.md)* -*Defined in [providers/provider.ts:37](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L37)* +*Defined in [providers/provider.ts:41](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L41)* ___ - + -## status +## transactions -**● status**: *[FinalTransactionStatus](../enums/_providers_provider_.finaltransactionstatus.md)* +**● transactions**: *[TransactionLog](_providers_provider_.transactionlog.md)[]* -*Defined in [providers/provider.ts:36](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L36)* +*Defined in [providers/provider.ts:42](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L42)* ___ diff --git a/docs/interfaces/_providers_provider_.nodestatusresult.md b/docs/interfaces/_providers_provider_.nodestatusresult.md index 59dbb9b8d9..b89c65c951 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/b17214a/src.ts/providers/provider.ts#L15)* +*Defined in [providers/provider.ts:15](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/provider.ts#L16)* +*Defined in [providers/provider.ts:16](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/provider.ts#L17)* +*Defined in [providers/provider.ts:17](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L17)* ___ @@ -39,7 +39,7 @@ ___ **● validators**: *`string`[]* -*Defined in [providers/provider.ts:18](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L18)* +*Defined in [providers/provider.ts:18](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L18)* ___ diff --git a/docs/interfaces/_providers_provider_.syncinfo.md b/docs/interfaces/_providers_provider_.syncinfo.md index 1f3d503395..bdcec91487 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/b17214a/src.ts/providers/provider.ts#L7)* +*Defined in [providers/provider.ts:7](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/provider.ts#L8)* +*Defined in [providers/provider.ts:8](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/provider.ts#L9)* +*Defined in [providers/provider.ts:9](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/providers/provider.ts#L10)* +*Defined in [providers/provider.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L10)* ___ @@ -48,7 +48,7 @@ ___ **● syncing**: *`boolean`* -*Defined in [providers/provider.ts:11](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L11)* +*Defined in [providers/provider.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L11)* ___ diff --git a/docs/interfaces/_providers_provider_.totalweight.md b/docs/interfaces/_providers_provider_.totalweight.md index 246d4e7a3a..3a903d98ee 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/b17214a/src.ts/providers/provider.ts#L41)* +*Defined in [providers/provider.ts:46](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L46)* ___ diff --git a/docs/interfaces/_providers_provider_.transaction.md b/docs/interfaces/_providers_provider_.transaction.md index 2c468b26dd..8341e10859 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/b17214a/src.ts/providers/provider.ts#L60)* +*Defined in [providers/provider.ts:65](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L65)* ___ @@ -21,7 +21,7 @@ ___ **● hash**: *`string`* -*Defined in [providers/provider.ts:57](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L57)* +*Defined in [providers/provider.ts:62](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L62)* ___ @@ -30,7 +30,7 @@ ___ **● public_key**: *`string`* -*Defined in [providers/provider.ts:58](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L58)* +*Defined in [providers/provider.ts:63](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L63)* ___ @@ -39,7 +39,7 @@ ___ **● signature**: *`string`* -*Defined in [providers/provider.ts:59](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L59)* +*Defined in [providers/provider.ts:64](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L64)* ___ diff --git a/docs/interfaces/_providers_provider_.transactionlog.md b/docs/interfaces/_providers_provider_.transactionlog.md index dbb78b2921..5b140d559d 100644 --- a/docs/interfaces/_providers_provider_.transactionlog.md +++ b/docs/interfaces/_providers_provider_.transactionlog.md @@ -12,34 +12,16 @@ **● hash**: *`string`* -*Defined in [providers/provider.ts:29](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L29)* - -___ - - -## lines - -**● lines**: *`string`[]* - -*Defined in [providers/provider.ts:30](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L30)* - -___ - - -## receipts - -**● receipts**: *`number`[][]* - -*Defined in [providers/provider.ts:31](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L31)* +*Defined in [providers/provider.ts:29](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L29)* ___ -## `` result +## result -**● result**: *`Uint8Array`* +**● result**: *[TransactionResult](_providers_provider_.transactionresult.md)* -*Defined in [providers/provider.ts:32](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L32)* +*Defined in [providers/provider.ts:30](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L30)* ___ diff --git a/docs/interfaces/_providers_provider_.transactionresult.md b/docs/interfaces/_providers_provider_.transactionresult.md new file mode 100644 index 0000000000..5ef738fb65 --- /dev/null +++ b/docs/interfaces/_providers_provider_.transactionresult.md @@ -0,0 +1,45 @@ + + +# Hierarchy + +**TransactionResult** + +# Properties + + + +## logs + +**● logs**: *`string`[]* + +*Defined in [providers/provider.ts:35](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L35)* + +___ + + +## receipts + +**● receipts**: *`string`[]* + +*Defined in [providers/provider.ts:36](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L36)* + +___ + + +## `` result + +**● result**: *`string`* + +*Defined in [providers/provider.ts:37](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L37)* + +___ + + +## status + +**● status**: *`string`* + +*Defined in [providers/provider.ts:34](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L34)* + +___ + diff --git a/docs/interfaces/_utils_key_pair_.signature.md b/docs/interfaces/_utils_key_pair_.signature.md index f3e29e1e0b..0f7820739c 100644 --- a/docs/interfaces/_utils_key_pair_.signature.md +++ b/docs/interfaces/_utils_key_pair_.signature.md @@ -10,9 +10,9 @@ ## publicKey -**● publicKey**: *`string`* +**● publicKey**: *[PublicKey](../classes/_utils_key_pair_.publickey.md)* -*Defined in [utils/key_pair.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L10)* +*Defined in [utils/key_pair.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/utils/key_pair.ts#L9)* +*Defined in [utils/key_pair.ts:9](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L9)* ___ diff --git a/docs/interfaces/_utils_network_.network.md b/docs/interfaces/_utils_network_.network.md index 65004e81d8..8c6782f79f 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/b17214a/src.ts/utils/network.ts#L6)* +*Defined in [utils/network.ts:6](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/utils/network.ts#L5)* +*Defined in [utils/network.ts:5](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/network.ts#L5)* ___ @@ -41,7 +41,7 @@ ___ **● name**: *`string`* -*Defined in [utils/network.ts:4](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/network.ts#L4)* +*Defined in [utils/network.ts:4](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/network.ts#L4)* ___ diff --git a/docs/interfaces/_utils_web_.connectioninfo.md b/docs/interfaces/_utils_web_.connectioninfo.md index 6a44624da5..04e92c06fe 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/b17214a/src.ts/utils/web.ts#L9)* +*Defined in [utils/web.ts:9](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L9)* ___ @@ -21,7 +21,7 @@ ___ **● headers**: *`object`* -*Defined in [utils/web.ts:11](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/web.ts#L11)* +*Defined in [utils/web.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/utils/web.ts#L8)* +*Defined in [utils/web.ts:8](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L8)* ___ @@ -43,7 +43,7 @@ ___ **● timeout**: *`number`* -*Defined in [utils/web.ts:10](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/web.ts#L10)* +*Defined in [utils/web.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L10)* ___ @@ -52,7 +52,7 @@ ___ **● url**: *`string`* -*Defined in [utils/web.ts:6](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/web.ts#L6)* +*Defined in [utils/web.ts:6](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L6)* ___ @@ -61,7 +61,7 @@ ___ **● user**: *`string`* -*Defined in [utils/web.ts:7](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/web.ts#L7)* +*Defined in [utils/web.ts:7](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L7)* ___ diff --git a/docs/modules/_account_.md b/docs/modules/_account_.md index df4f4b89c0..8dfba725b9 100644 --- a/docs/modules/_account_.md +++ b/docs/modules/_account_.md @@ -31,7 +31,7 @@ **● DEFAULT_FUNC_CALL_AMOUNT**: *`1000000`* = 1000000 -*Defined in [account.ts:13](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L13)* +*Defined in [account.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L14)* ___ @@ -40,7 +40,7 @@ ___ **● TX_STATUS_RETRY_NUMBER**: *`10`* = 10 -*Defined in [account.ts:16](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L16)* +*Defined in [account.ts:17](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L17)* ___ @@ -49,7 +49,7 @@ ___ **● TX_STATUS_RETRY_WAIT**: *`500`* = 500 -*Defined in [account.ts:19](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L19)* +*Defined in [account.ts:20](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L20)* ___ @@ -58,7 +58,7 @@ ___ **● TX_STATUS_RETRY_WAIT_BACKOFF**: *`1.5`* = 1.5 -*Defined in [account.ts:22](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L22)* +*Defined in [account.ts:23](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L23)* ___ @@ -70,7 +70,7 @@ ___ ▸ **sleep**(millis: *`number`*): `Promise`<`any`> -*Defined in [account.ts:25](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/account.ts#L25)* +*Defined in [account.ts:26](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/account.ts#L26)* **Parameters:** diff --git a/docs/modules/_connection_.md b/docs/modules/_connection_.md index e305a0aa57..be655a0047 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/b17214a/src.ts/connection.ts#L6)* +*Defined in [connection.ts:6](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/connection.ts#L13)* +*Defined in [connection.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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 4fcb657775..9193c3babc 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/b17214a/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/b6e94a8/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 3fd1f12af5..7f686f056b 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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/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/b17214a/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/b6e94a8/src.ts/key_stores/unencrypted_file_system_keystore.ts#L9)* **Parameters:** diff --git a/docs/modules/_near_.md b/docs/modules/_near_.md index 0ab436dd9a..306a034d70 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/b17214a/src.ts/near.ts#L84)* +*Defined in [near.ts:72](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/near.ts#L72)* **Parameters:** diff --git a/docs/modules/_providers_json_rpc_provider_.md b/docs/modules/_providers_json_rpc_provider_.md index 8283027649..5e33b4eddb 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/b17214a/src.ts/providers/json-rpc-provider.ts#L10)* +*Defined in [providers/json-rpc-provider.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/json-rpc-provider.ts#L10)* ___ diff --git a/docs/modules/_providers_provider_.md b/docs/modules/_providers_provider_.md index 78e1db0080..67a41b22e4 100644 --- a/docs/modules/_providers_provider_.md +++ b/docs/modules/_providers_provider_.md @@ -20,6 +20,7 @@ * [TotalWeight](../interfaces/_providers_provider_.totalweight.md) * [Transaction](../interfaces/_providers_provider_.transaction.md) * [TransactionLog](../interfaces/_providers_provider_.transactionlog.md) +* [TransactionResult](../interfaces/_providers_provider_.transactionresult.md) ### Functions @@ -35,7 +36,7 @@ ▸ **getTransactionLastResult**(txResult: *[FinalTransactionResult](../interfaces/_providers_provider_.finaltransactionresult.md)*): `any` -*Defined in [providers/provider.ts:78](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/providers/provider.ts#L78)* +*Defined in [providers/provider.ts:83](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/providers/provider.ts#L83)* **Parameters:** diff --git a/docs/modules/_transaction_.md b/docs/modules/_transaction_.md index 6500f21f3c..ef8eb8fc07 100644 --- a/docs/modules/_transaction_.md +++ b/docs/modules/_transaction_.md @@ -2,10 +2,6 @@ # Index -### Enumerations - -* [KeyType](../enums/_transaction_.keytype.md) - ### Classes * [AccessKey](../classes/_transaction_.accesskey.md) @@ -22,7 +18,6 @@ * [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) @@ -58,7 +53,7 @@ **● SCHEMA**: *`Map`<`Function`, `any`>* = new Map([ [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]]] }], + [Transaction, { kind: 'struct', fields: [['signerId', 'string'], ['publicKey', PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['blockHash', [32]], ['actions', [Action]]] }], [PublicKey, { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }], [AccessKey, { kind: 'struct', fields: [ @@ -95,7 +90,7 @@ [DeleteAccount, { kind: 'struct', fields: [['beneficiaryId', 'string']] }], ]) -*Defined in [transaction.ts:152](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L152)* +*Defined in [transaction.ts:140](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L140)* ___ @@ -105,15 +100,15 @@ ___ ## addKey -▸ **addKey**(publicKey: *`string`*, accessKey: *[AccessKey](../classes/_transaction_.accesskey.md)*): [Action](../classes/_transaction_.action.md) +▸ **addKey**(publicKey: *[PublicKey](../classes/_utils_key_pair_.publickey.md)*, accessKey: *[AccessKey](../classes/_transaction_.accesskey.md)*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:88](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L88)* +*Defined in [transaction.ts:89](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L89)* **Parameters:** | Name | Type | | ------ | ------ | -| publicKey | `string` | +| publicKey | [PublicKey](../classes/_utils_key_pair_.publickey.md) | | accessKey | [AccessKey](../classes/_transaction_.accesskey.md) | **Returns:** [Action](../classes/_transaction_.action.md) @@ -125,7 +120,7 @@ ___ ▸ **createAccount**(): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:68](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L68)* +*Defined in [transaction.ts:69](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L69)* **Returns:** [Action](../classes/_transaction_.action.md) @@ -136,7 +131,7 @@ ___ ▸ **deleteAccount**(beneficiaryId: *`string`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:96](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L96)* +*Defined in [transaction.ts:97](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L97)* **Parameters:** @@ -151,15 +146,15 @@ ___ ## deleteKey -▸ **deleteKey**(publicKey: *`string`*): [Action](../classes/_transaction_.action.md) +▸ **deleteKey**(publicKey: *[PublicKey](../classes/_utils_key_pair_.publickey.md)*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:92](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L92)* +*Defined in [transaction.ts:93](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L93)* **Parameters:** | Name | Type | | ------ | ------ | -| publicKey | `string` | +| publicKey | [PublicKey](../classes/_utils_key_pair_.publickey.md) | **Returns:** [Action](../classes/_transaction_.action.md) @@ -170,7 +165,7 @@ ___ ▸ **deployContract**(code: *`Uint8Array`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:72](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L72)* +*Defined in [transaction.ts:73](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L73)* **Parameters:** @@ -187,7 +182,7 @@ ___ ▸ **fullAccessKey**(): [AccessKey](../classes/_transaction_.accesskey.md) -*Defined in [transaction.ts:49](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L49)* +*Defined in [transaction.ts:50](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L50)* **Returns:** [AccessKey](../classes/_transaction_.accesskey.md) @@ -198,7 +193,7 @@ ___ ▸ **functionCall**(methodName: *`string`*, args: *`Uint8Array`*, gas: *`number`*, deposit: *`BN`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:76](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L76)* +*Defined in [transaction.ts:77](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L77)* **Parameters:** @@ -218,7 +213,7 @@ ___ ▸ **functionCallAccessKey**(receiverId: *`string`*, methodNames: *`String`[]*, allowance?: *`BN`*): [AccessKey](../classes/_transaction_.accesskey.md) -*Defined in [transaction.ts:53](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L53)* +*Defined in [transaction.ts:54](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L54)* **Parameters:** @@ -235,9 +230,9 @@ ___ ## signTransaction -▸ **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)]> +▸ **signTransaction**(receiverId: *`string`*, nonce: *`number`*, actions: *[Action](../classes/_transaction_.action.md)[]*, blockHash: *`Uint8Array`*, signer: *[Signer](../classes/_signer_.signer.md)*, accountId?: *`string`*, networkId?: *`string`*): `Promise`<[`Uint8Array`, [SignedTransaction](../classes/_transaction_.signedtransaction.md)]> -*Defined in [transaction.ts:192](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L192)* +*Defined in [transaction.ts:180](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L180)* **Parameters:** @@ -246,6 +241,7 @@ ___ | receiverId | `string` | | nonce | `number` | | actions | [Action](../classes/_transaction_.action.md)[] | +| blockHash | `Uint8Array` | | signer | [Signer](../classes/_signer_.signer.md) | | `Optional` accountId | `string` | | `Optional` networkId | `string` | @@ -257,16 +253,16 @@ ___ ## stake -▸ **stake**(stake: *`BN`*, publicKey: *`string`*): [Action](../classes/_transaction_.action.md) +▸ **stake**(stake: *`BN`*, publicKey: *[PublicKey](../classes/_utils_key_pair_.publickey.md)*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:84](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L84)* +*Defined in [transaction.ts:85](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L85)* **Parameters:** | Name | Type | | ------ | ------ | | stake | `BN` | -| publicKey | `string` | +| publicKey | [PublicKey](../classes/_utils_key_pair_.publickey.md) | **Returns:** [Action](../classes/_transaction_.action.md) @@ -277,7 +273,7 @@ ___ ▸ **transfer**(deposit: *`BN`*): [Action](../classes/_transaction_.action.md) -*Defined in [transaction.ts:80](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/transaction.ts#L80)* +*Defined in [transaction.ts:81](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/transaction.ts#L81)* **Parameters:** diff --git a/docs/modules/_utils_key_pair_.md b/docs/modules/_utils_key_pair_.md index 98160feb9d..28c2c35f22 100644 --- a/docs/modules/_utils_key_pair_.md +++ b/docs/modules/_utils_key_pair_.md @@ -2,10 +2,15 @@ # Index +### Enumerations + +* [KeyType](../enums/_utils_key_pair_.keytype.md) + ### Classes * [KeyPair](../classes/_utils_key_pair_.keypair.md) * [KeyPairEd25519](../classes/_utils_key_pair_.keypaired25519.md) +* [PublicKey](../classes/_utils_key_pair_.publickey.md) ### Interfaces @@ -15,6 +20,11 @@ * [Arrayish](_utils_key_pair_.md#arrayish) +### Functions + +* [key_type_to_str](_utils_key_pair_.md#key_type_to_str) +* [str_to_key_type](_utils_key_pair_.md#str_to_key_type) + --- # Type aliases @@ -25,7 +35,44 @@ **Ƭ Arrayish**: *`string` \| `ArrayLike`<`number`>* -*Defined in [utils/key_pair.ts:6](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/key_pair.ts#L6)* +*Defined in [utils/key_pair.ts:6](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L6)* + +___ + +# Functions + + + +## key_type_to_str + +▸ **key_type_to_str**(key_type: *[KeyType](../enums/_utils_key_pair_.keytype.md)*): `String` + +*Defined in [utils/key_pair.ts:18](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L18)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| key_type | [KeyType](../enums/_utils_key_pair_.keytype.md) | + +**Returns:** `String` + +___ + + +## str_to_key_type + +▸ **str_to_key_type**(key_type: *`string`*): [KeyType](../enums/_utils_key_pair_.keytype.md) + +*Defined in [utils/key_pair.ts:25](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/key_pair.ts#L25)* + +**Parameters:** + +| Name | Type | +| ------ | ------ | +| key_type | `string` | + +**Returns:** [KeyType](../enums/_utils_key_pair_.keytype.md) ___ diff --git a/docs/modules/_utils_serialize_.md b/docs/modules/_utils_serialize_.md index a65fdba5fc..7cad3a8b56 100644 --- a/docs/modules/_utils_serialize_.md +++ b/docs/modules/_utils_serialize_.md @@ -36,7 +36,7 @@ **Ƭ Schema**: *`Map`<`Function`, `any`>* -*Defined in [utils/serialize.ts:19](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L19)* +*Defined in [utils/serialize.ts:19](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L19)* ___ @@ -48,7 +48,7 @@ ___ **● INITIAL_LENGTH**: *`1024`* = 1024 -*Defined in [utils/serialize.ts:17](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L17)* +*Defined in [utils/serialize.ts:17](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L17)* ___ @@ -60,7 +60,7 @@ ___ ▸ **base_decode**(value: *`string`*): `Uint8Array` -*Defined in [utils/serialize.ts:13](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L13)* +*Defined in [utils/serialize.ts:13](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L13)* **Parameters:** @@ -77,7 +77,7 @@ ___ ▸ **base_encode**(value: *`Uint8Array` \| `string`*): `string` -*Defined in [utils/serialize.ts:6](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L6)* +*Defined in [utils/serialize.ts:6](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L6)* **Parameters:** @@ -94,7 +94,7 @@ ___ ▸ **deserialize**(schema: *[Schema](_utils_serialize_.md#schema)*, classType: *`any`*, buffer: *`Buffer`*): `any` -*Defined in [utils/serialize.ts:228](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L228)* +*Defined in [utils/serialize.ts:228](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L228)* **Parameters:** @@ -113,7 +113,7 @@ ___ ▸ **deserializeField**(schema: *[Schema](_utils_serialize_.md#schema)*, fieldType: *`any`*, reader: *`any`*): `any` -*Defined in [utils/serialize.ts:206](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L206)* +*Defined in [utils/serialize.ts:206](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L206)* **Parameters:** @@ -132,7 +132,7 @@ ___ ▸ **deserializeStruct**(schema: *[Schema](_utils_serialize_.md#schema)*, classType: *`any`*, reader: *`any`*): `any` -*Defined in [utils/serialize.ts:220](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L220)* +*Defined in [utils/serialize.ts:220](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L220)* **Parameters:** @@ -151,7 +151,7 @@ ___ ▸ **serialize**(schema: *[Schema](_utils_serialize_.md#schema)*, obj: *`any`*): `Uint8Array` -*Defined in [utils/serialize.ts:200](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L200)* +*Defined in [utils/serialize.ts:200](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L200)* **Parameters:** @@ -169,7 +169,7 @@ ___ ▸ **serializeField**(schema: *[Schema](_utils_serialize_.md#schema)*, value: *`any`*, fieldType: *`any`*, writer: *`any`*): `void` -*Defined in [utils/serialize.ts:147](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L147)* +*Defined in [utils/serialize.ts:147](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L147)* **Parameters:** @@ -189,7 +189,7 @@ ___ ▸ **serializeStruct**(schema: *[Schema](_utils_serialize_.md#schema)*, obj: *`any`*, writer: *`any`*): `void` -*Defined in [utils/serialize.ts:174](https://github.com/nearprotocol/nearlib/blob/b17214a/src.ts/utils/serialize.ts#L174)* +*Defined in [utils/serialize.ts:174](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/serialize.ts#L174)* **Parameters:** diff --git a/docs/modules/_utils_web_.md b/docs/modules/_utils_web_.md index 7cedf56b47..4a95284f1e 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/b17214a/src.ts/utils/web.ts#L14)* +*Defined in [utils/web.ts:14](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/utils/web.ts#L16)* +*Defined in [utils/web.ts:16](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/utils/web.ts#L16)* **Parameters:** diff --git a/docs/modules/_wallet_account_.md b/docs/modules/_wallet_account_.md index 27096a6baf..5f30a68a6f 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/b17214a/src.ts/wallet-account.ts#L10)* +*Defined in [wallet-account.ts:10](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L8)* +*Defined in [wallet-account.ts:8](https://github.com/nearprotocol/nearlib/blob/b6e94a8/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/b17214a/src.ts/wallet-account.ts#L11)* +*Defined in [wallet-account.ts:11](https://github.com/nearprotocol/nearlib/blob/b6e94a8/src.ts/wallet-account.ts#L11)* ___ diff --git a/lib/account.d.ts b/lib/account.d.ts index 085b5c2083..34d240d078 100644 --- a/lib/account.d.ts +++ b/lib/account.d.ts @@ -1,6 +1,7 @@ import BN from 'bn.js'; import { FinalTransactionResult } from './providers/provider'; import { Connection } from './connection'; +import { PublicKey } from './utils/key_pair'; export interface AccountState { account_id: string; amount: string; @@ -20,14 +21,14 @@ export declare class Account { private printLogs; private retryTxResult; private signAndSendTransaction; - createAndDeployContract(contractId: string, publicKey: string, data: Uint8Array, amount: BN): Promise; + createAndDeployContract(contractId: string, publicKey: string | PublicKey, data: Uint8Array, amount: BN): Promise; sendMoney(receiverId: string, amount: BN): Promise; - createAccount(newAccountId: string, publicKey: string, amount: BN): Promise; + createAccount(newAccountId: string, publicKey: string | PublicKey, amount: BN): Promise; deployContract(data: Uint8Array): Promise; functionCall(contractId: string, methodName: string, args: any, gas: number, amount?: BN): Promise; - addKey(publicKey: string, contractId?: string, methodName?: string, amount?: BN): Promise; - deleteKey(publicKey: string): Promise; - stake(publicKey: string, amount: BN): Promise; + addKey(publicKey: string | PublicKey, contractId?: string, methodName?: string, amount?: BN): Promise; + deleteKey(publicKey: string | PublicKey): Promise; + stake(publicKey: string | PublicKey, amount: BN): Promise; viewFunction(contractId: string, methodName: string, args: any): Promise; getAccessKeys(): Promise; getAccountDetails(): Promise; diff --git a/lib/account.js b/lib/account.js index 2cf337f29e..2d58fe4746 100644 --- a/lib/account.js +++ b/lib/account.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const transaction_1 = require("./transaction"); const provider_1 = require("./providers/provider"); const serialize_1 = require("./utils/serialize"); +const key_pair_1 = require("./utils/key_pair"); // 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. @@ -28,8 +29,11 @@ class Account { async fetchState() { this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); try { - const publicKey = await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId); + const publicKey = (await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId)).toString(); this._accessKey = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); + if (this._accessKey === null) { + throw new Error(`Failed to fetch access key for '${this.accountId}' with public key ${publicKey}`); + } } catch { this._accessKey = null; @@ -90,10 +94,9 @@ class Account { return result; } async createAndDeployContract(contractId, publicKey, data, amount) { - await this.createAccount(contractId, publicKey, amount); + const accessKey = transaction_1.fullAccessKey(); + await this.signAndSendTransaction(contractId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey), transaction_1.deployContract(data)]); const contractAccount = new Account(this.connection, contractId); - await contractAccount.ready; - await contractAccount.deployContract(data); return contractAccount; } async sendMoney(receiverId, amount) { @@ -101,7 +104,7 @@ class Account { } async createAccount(newAccountId, publicKey, amount) { const accessKey = transaction_1.fullAccessKey(); - return this.signAndSendTransaction(newAccountId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(newAccountId, [transaction_1.createAccount(), transaction_1.transfer(amount), transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey)]); } async deployContract(data) { return this.signAndSendTransaction(this.accountId, [transaction_1.deployContract(data)]); @@ -121,13 +124,13 @@ class Account { else { accessKey = transaction_1.functionCallAccessKey(contractId, !methodName ? [] : [methodName], amount); } - return this.signAndSendTransaction(this.accountId, [transaction_1.addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.addKey(key_pair_1.PublicKey.from(publicKey), accessKey)]); } async deleteKey(publicKey) { - return this.signAndSendTransaction(this.accountId, [transaction_1.deleteKey(publicKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.deleteKey(key_pair_1.PublicKey.from(publicKey))]); } async stake(publicKey, amount) { - return this.signAndSendTransaction(this.accountId, [transaction_1.stake(amount, publicKey)]); + return this.signAndSendTransaction(this.accountId, [transaction_1.stake(amount, key_pair_1.PublicKey.from(publicKey))]); } async viewFunction(contractId, methodName, args) { const result = await this.connection.provider.query(`call/${contractId}/${methodName}`, serialize_1.base_encode(JSON.stringify(args))); diff --git a/lib/account_creator.d.ts b/lib/account_creator.d.ts index 9d49b4451a..8d0689531e 100644 --- a/lib/account_creator.d.ts +++ b/lib/account_creator.d.ts @@ -2,21 +2,22 @@ import BN from 'bn.js'; import { Connection } from './connection'; import { Account } from './account'; import { ConnectionInfo } from './utils/web'; +import { PublicKey } from './utils/key_pair'; /** * Account creator provides interface to specific implementation to acutally create account. */ export declare abstract class AccountCreator { - abstract createAccount(newAccountId: string, publicKey: string): Promise; + abstract createAccount(newAccountId: string, publicKey: PublicKey): Promise; } export declare class LocalAccountCreator extends AccountCreator { readonly masterAccount: Account; readonly initialBalance: BN; constructor(masterAccount: Account, initialBalance: BN); - createAccount(newAccountId: string, publicKey: string): Promise; + createAccount(newAccountId: string, publicKey: PublicKey): Promise; } export declare class UrlAccountCreator extends AccountCreator { readonly connection: Connection; readonly helperConnection: ConnectionInfo; constructor(connection: Connection, helperUrl: string); - createAccount(newAccountId: string, publicKey: string): Promise; + createAccount(newAccountId: string, publicKey: PublicKey): Promise; } diff --git a/lib/near.d.ts b/lib/near.d.ts index 20fb6f4165..7a18a64326 100644 --- a/lib/near.d.ts +++ b/lib/near.d.ts @@ -2,6 +2,7 @@ import BN from 'bn.js'; import { Account } from './account'; import { Connection } from './connection'; import { Contract } from './contract'; +import { PublicKey } from './utils/key_pair'; import { AccountCreator } from './account_creator'; export declare class Near { readonly config: any; @@ -9,7 +10,7 @@ export declare class Near { readonly accountCreator: AccountCreator; constructor(config: any); account(accountId: string): Promise; - createAccount(accountId: string, publicKey: string): Promise; + createAccount(accountId: string, publicKey: PublicKey): Promise; /** * Backwards compatibility method. Use `new nearlib.Contract(yourAccount, contractId, { viewMethods, changeMethods })` instead. * @param contractId diff --git a/lib/signer.d.ts b/lib/signer.d.ts index 318e0459e5..623e039d27 100644 --- a/lib/signer.d.ts +++ b/lib/signer.d.ts @@ -1,4 +1,4 @@ -import { Signature } from './utils/key_pair'; +import { Signature, PublicKey } from './utils/key_pair'; import { KeyStore } from './key_stores'; /** * General signing interface, can be used for in memory signing, RPC singing, external wallet, HSM, etc. @@ -7,13 +7,13 @@ export declare abstract class Signer { /** * Creates new key and returns public key. */ - abstract createKey(accountId: string, networkId?: string): Promise; + abstract createKey(accountId: string, networkId?: string): Promise; /** * Returns public key for given account / network. * @param accountId accountId to retrieve from. * @param networkId network for this accountId. */ - abstract getPublicKey(accountId?: string, networkId?: string): Promise; + abstract getPublicKey(accountId?: string, networkId?: string): Promise; /** * Signs given hash. * @param hash hash to sign. @@ -35,7 +35,7 @@ export declare abstract class Signer { export declare class InMemorySigner extends Signer { readonly keyStore: KeyStore; constructor(keyStore: KeyStore); - createKey(accountId: string, networkId: string): Promise; - getPublicKey(accountId?: string, networkId?: string): Promise; + createKey(accountId: string, networkId: string): Promise; + getPublicKey(accountId?: string, networkId?: string): Promise; signHash(hash: Uint8Array, accountId?: string, networkId?: string): Promise; } diff --git a/lib/transaction.d.ts b/lib/transaction.d.ts index 7ad10b9c9c..a224742c2b 100644 --- a/lib/transaction.d.ts +++ b/lib/transaction.d.ts @@ -1,4 +1,5 @@ import BN from 'bn.js'; +import { KeyType, PublicKey } from './utils/key_pair'; import { Signer } from './signer'; declare class Enum { enum: string; @@ -58,18 +59,10 @@ export declare function createAccount(): Action; export declare function deployContract(code: Uint8Array): Action; export declare function functionCall(methodName: string, args: Uint8Array, gas: number, deposit: BN): Action; export declare function transfer(deposit: BN): Action; -export declare function stake(stake: BN, publicKey: string): Action; -export declare function addKey(publicKey: string, accessKey: AccessKey): Action; -export declare function deleteKey(publicKey: string): Action; +export declare function stake(stake: BN, publicKey: PublicKey): Action; +export declare function addKey(publicKey: PublicKey, accessKey: AccessKey): Action; +export declare function deleteKey(publicKey: PublicKey): Action; export declare function deleteAccount(beneficiaryId: string): Action; -declare enum KeyType { - ED25519 = 0 -} -declare class PublicKey { - keyType: KeyType; - data: Uint8Array; - constructor(publicKey: string); -} declare class Signature { keyType: KeyType; data: Uint8Array; diff --git a/lib/transaction.js b/lib/transaction.js index 12166eb9e6..b219cde746 100644 --- a/lib/transaction.js +++ b/lib/transaction.js @@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const js_sha256_1 = __importDefault(require("js-sha256")); const serialize_1 = require("./utils/serialize"); +const key_pair_1 = require("./utils/key_pair"); class Enum { constructor(properties) { if (Object.keys(properties).length !== 1) { @@ -79,34 +80,24 @@ function transfer(deposit) { } exports.transfer = transfer; function stake(stake, publicKey) { - return new Action({ stake: new Stake({ stake, publicKey: new PublicKey(publicKey) }) }); + return new Action({ stake: new Stake({ stake, publicKey }) }); } exports.stake = stake; function addKey(publicKey, accessKey) { - return new Action({ addKey: new AddKey({ publicKey: new PublicKey(publicKey), accessKey }) }); + return new Action({ addKey: new AddKey({ publicKey, accessKey }) }); } exports.addKey = addKey; function deleteKey(publicKey) { - return new Action({ deleteKey: new DeleteKey({ publicKey: new PublicKey(publicKey) }) }); + return new Action({ deleteKey: new DeleteKey({ 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.keyType = key_pair_1.KeyType.ED25519; this.data = signature; } } @@ -124,8 +115,8 @@ exports.Action = Action; const SCHEMA = new Map([ [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'], ['blockHash', [32]], ['actions', [Action]]] }], - [PublicKey, { + [Transaction, { kind: 'struct', fields: [['signerId', 'string'], ['publicKey', key_pair_1.PublicKey], ['nonce', 'u64'], ['receiverId', 'string'], ['blockHash', [32]], ['actions', [Action]]] }], + [key_pair_1.PublicKey, { kind: 'struct', fields: [['keyType', 'u8'], ['data', [32]]] }], [AccessKey, { kind: 'struct', fields: [ @@ -156,13 +147,13 @@ const SCHEMA = new Map([ [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]] }], + [Stake, { kind: 'struct', fields: [['stake', 'u128'], ['publicKey', key_pair_1.PublicKey]] }], + [AddKey, { kind: 'struct', fields: [['publicKey', key_pair_1.PublicKey], ['accessKey', AccessKey]] }], + [DeleteKey, { kind: 'struct', fields: [['publicKey', key_pair_1.PublicKey]] }], [DeleteAccount, { kind: 'struct', fields: [['beneficiaryId', 'string']] }], ]); async function signTransaction(receiverId, nonce, actions, blockHash, signer, accountId, networkId) { - const publicKey = new PublicKey(await signer.getPublicKey(accountId, networkId)); + const publicKey = await signer.getPublicKey(accountId, networkId); const transaction = new Transaction({ signerId: accountId, publicKey, nonce, receiverId, actions, blockHash }); const message = serialize_1.serialize(SCHEMA, transaction); const hash = new Uint8Array(js_sha256_1.default.sha256.array(message)); diff --git a/lib/utils/key_pair.d.ts b/lib/utils/key_pair.d.ts index b1262a7255..3b0745ead5 100644 --- a/lib/utils/key_pair.d.ts +++ b/lib/utils/key_pair.d.ts @@ -1,13 +1,28 @@ export declare type Arrayish = string | ArrayLike; export interface Signature { signature: Uint8Array; - publicKey: string; + publicKey: PublicKey; +} +/** All supported key types */ +export declare enum KeyType { + ED25519 = 0 +} +/** + * PublicKey representation that has type and bytes of the key. + */ +export declare class PublicKey { + keyType: KeyType; + data: Uint8Array; + constructor(keyType: KeyType, data: Uint8Array); + static from(value: string | PublicKey): PublicKey; + static fromString(encodedKey: string): PublicKey; + toString(): string; } export declare abstract class KeyPair { abstract sign(message: Uint8Array): Signature; abstract verify(message: Uint8Array, signature: Uint8Array): boolean; abstract toString(): string; - abstract getPublicKey(): string; + abstract getPublicKey(): PublicKey; static fromRandom(curve: string): KeyPair; static fromString(encodedKey: string): KeyPair; } @@ -16,7 +31,7 @@ export declare abstract class KeyPair { * generating key pairs, encoding key pairs, signing and verifying. */ export declare class KeyPairEd25519 extends KeyPair { - readonly publicKey: string; + readonly publicKey: PublicKey; readonly secretKey: string; /** * Construct an instance of key pair given a secret key. @@ -38,5 +53,5 @@ export declare class KeyPairEd25519 extends KeyPair { sign(message: Uint8Array): Signature; verify(message: Uint8Array, signature: Uint8Array): boolean; toString(): string; - getPublicKey(): string; + getPublicKey(): PublicKey; } diff --git a/lib/utils/key_pair.js b/lib/utils/key_pair.js index 3e2bf545b9..d106845924 100644 --- a/lib/utils/key_pair.js +++ b/lib/utils/key_pair.js @@ -5,21 +5,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const tweetnacl_1 = __importDefault(require("tweetnacl")); const serialize_1 = require("./serialize"); +/** All supported key types */ +var KeyType; +(function (KeyType) { + KeyType[KeyType["ED25519"] = 0] = "ED25519"; +})(KeyType = exports.KeyType || (exports.KeyType = {})); +function key_type_to_str(key_type) { + switch (key_type) { + case KeyType.ED25519: return 'ED25519'; + default: throw new Error(`Unknown key type ${key_type}`); + } +} +function str_to_key_type(key_type) { + switch (key_type.toUpperCase()) { + case 'ED25519': return KeyType.ED25519; + default: throw new Error(`Unknown key type ${key_type}`); + } +} +/** + * PublicKey representation that has type and bytes of the key. + */ +class PublicKey { + constructor(keyType, data) { + this.keyType = keyType; + this.data = data; + } + static from(value) { + if (typeof value === 'string') { + return PublicKey.fromString(value); + } + return value; + } + static fromString(encodedKey) { + const parts = encodedKey.split(':'); + if (parts.length == 1) { + return new PublicKey(KeyType.ED25519, serialize_1.base_decode(parts[0])); + } + else if (parts.length == 2) { + return new PublicKey(str_to_key_type(parts[0]), serialize_1.base_decode(parts[1])); + } + else { + throw new Error('Invlaid encoded key format, must be :'); + } + } + toString() { + return `${key_type_to_str(this.keyType)}:${serialize_1.base_encode(this.data)}`; + } +} +exports.PublicKey = PublicKey; class KeyPair { static fromRandom(curve) { - switch (curve) { - case 'ed25519': return KeyPairEd25519.fromRandom(); + switch (curve.toUpperCase()) { + 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 :'); + if (parts.length == 1) { + return new KeyPairEd25519(parts[0]); } - switch (parts[0]) { - case 'ed25519': return new KeyPairEd25519(parts[1]); - default: throw new Error(`Unknown curve: ${parts[0]}`); + else if (parts.length == 2) { + switch (parts[0].toUpperCase()) { + case 'ED25519': return new KeyPairEd25519(parts[1]); + default: throw new Error(`Unknown curve: ${parts[0]}`); + } + } + else { + throw new Error('Invalid encoded key format, must be :'); } } } @@ -37,7 +90,7 @@ class KeyPairEd25519 extends KeyPair { 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.publicKey = new PublicKey(KeyType.ED25519, keyPair.publicKey); this.secretKey = secretKey; } /** @@ -59,7 +112,7 @@ class KeyPairEd25519 extends KeyPair { return { signature, publicKey: this.publicKey }; } verify(message, signature) { - return tweetnacl_1.default.sign.detached.verify(message, signature, serialize_1.base_decode(this.publicKey)); + return tweetnacl_1.default.sign.detached.verify(message, signature, this.publicKey.data); } toString() { return `ed25519:${this.secretKey}`; diff --git a/lib/wallet-account.js b/lib/wallet-account.js index adb2ed8b68..965ffc4917 100644 --- a/lib/wallet-account.js +++ b/lib/wallet-account.js @@ -57,7 +57,7 @@ class WalletAccount { 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()); + newUrl.searchParams.set('public_key', accessKey.getPublicKey().toString()); await this._keyStore.setKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + accessKey.getPublicKey(), accessKey); window.location.assign(newUrl.toString()); } diff --git a/src.ts/account.ts b/src.ts/account.ts index d29967efd4..894945ad9f 100644 --- a/src.ts/account.ts +++ b/src.ts/account.ts @@ -6,6 +6,7 @@ import { Action, transfer, createAccount, signTransaction, deployContract, import { FinalTransactionResult, FinalTransactionStatus } from './providers/provider'; import { Connection } from './connection'; import {base_decode, base_encode} from './utils/serialize'; +import { PublicKey } from './utils/key_pair'; // 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 @@ -52,8 +53,11 @@ export class Account { async fetchState(): Promise { this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); try { - const publicKey = await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId); + const publicKey = (await this.connection.signer.getPublicKey(this.accountId, this.connection.networkId)).toString(); this._accessKey = await this.connection.provider.query(`access_key/${this.accountId}/${publicKey}`, ''); + if (this._accessKey === null) { + throw new Error(`Failed to fetch access key for '${this.accountId}' with public key ${publicKey}`); + } } catch { this._accessKey = null; } @@ -122,11 +126,10 @@ export class Account { return result; } - async createAndDeployContract(contractId: string, publicKey: string, data: Uint8Array, amount: BN): Promise { - await this.createAccount(contractId, publicKey, amount); + async createAndDeployContract(contractId: string, publicKey: string | PublicKey, data: Uint8Array, amount: BN): Promise { + const accessKey = fullAccessKey(); + await this.signAndSendTransaction(contractId, [createAccount(), transfer(amount), addKey(PublicKey.from(publicKey), accessKey), deployContract(data)]); const contractAccount = new Account(this.connection, contractId); - await contractAccount.ready; - await contractAccount.deployContract(data); return contractAccount; } @@ -134,9 +137,9 @@ export class Account { return this.signAndSendTransaction(receiverId, [transfer(amount)]); } - async createAccount(newAccountId: string, publicKey: string, amount: BN): Promise { + async createAccount(newAccountId: string, publicKey: string | PublicKey, amount: BN): Promise { const accessKey = fullAccessKey(); - return this.signAndSendTransaction(newAccountId, [createAccount(), transfer(amount), addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(newAccountId, [createAccount(), transfer(amount), addKey(PublicKey.from(publicKey), accessKey)]); } async deployContract(data: Uint8Array): Promise { @@ -151,22 +154,22 @@ export class Account { } // TODO: expand this API to support more options. - async addKey(publicKey: string, contractId?: string, methodName?: string, amount?: BN): Promise { + async addKey(publicKey: string | PublicKey, contractId?: string, methodName?: string, amount?: BN): Promise { let accessKey; if (contractId === null || contractId === undefined) { accessKey = fullAccessKey(); } else { accessKey = functionCallAccessKey(contractId, !methodName ? [] : [methodName], amount); } - return this.signAndSendTransaction(this.accountId, [addKey(publicKey, accessKey)]); + return this.signAndSendTransaction(this.accountId, [addKey(PublicKey.from(publicKey), accessKey)]); } - async deleteKey(publicKey: string): Promise { - return this.signAndSendTransaction(this.accountId, [deleteKey(publicKey)]); + async deleteKey(publicKey: string | PublicKey): Promise { + return this.signAndSendTransaction(this.accountId, [deleteKey(PublicKey.from(publicKey))]); } - async stake(publicKey: string, amount: BN): Promise { - return this.signAndSendTransaction(this.accountId, [stake(amount, publicKey)]); + async stake(publicKey: string | PublicKey, amount: BN): Promise { + return this.signAndSendTransaction(this.accountId, [stake(amount, PublicKey.from(publicKey))]); } async viewFunction(contractId: string, methodName: string, args: any): Promise { diff --git a/src.ts/account_creator.ts b/src.ts/account_creator.ts index 6352056623..e315a903ff 100644 --- a/src.ts/account_creator.ts +++ b/src.ts/account_creator.ts @@ -2,12 +2,13 @@ import BN from 'bn.js'; import { Connection } from './connection'; import { Account } from './account'; import { ConnectionInfo } from './utils/web'; +import { PublicKey } from './utils/key_pair'; /** * Account creator provides interface to specific implementation to acutally create account. */ export abstract class AccountCreator { - abstract async createAccount(newAccountId: string, publicKey: string): Promise; + abstract async createAccount(newAccountId: string, publicKey: PublicKey): Promise; } export class LocalAccountCreator extends AccountCreator { @@ -20,7 +21,7 @@ export class LocalAccountCreator extends AccountCreator { this.initialBalance = initialBalance; } - async createAccount(newAccountId: string, publicKey: string): Promise { + async createAccount(newAccountId: string, publicKey: PublicKey): Promise { await this.masterAccount.createAccount(newAccountId, publicKey, this.initialBalance); // TODO: check the response here for status and raise if didn't complete. } @@ -36,7 +37,7 @@ export class UrlAccountCreator extends AccountCreator { this.helperConnection = { url: helperUrl }; } - async createAccount(newAccountId: string, publicKey: string): Promise { + async createAccount(newAccountId: string, publicKey: PublicKey): Promise { // TODO: hit url to create account. } } diff --git a/src.ts/near.ts b/src.ts/near.ts index 7a3c5b6d98..7e6e765c0a 100644 --- a/src.ts/near.ts +++ b/src.ts/near.ts @@ -4,7 +4,7 @@ import { Account } from './account'; import { Connection } from './connection'; import { Contract } from './contract'; import { loadJsonFile } from './key_stores/unencrypted_file_system_keystore'; -import { KeyPair } from './utils/key_pair'; +import { KeyPair, PublicKey } from './utils/key_pair'; import { AccountCreator, LocalAccountCreator, UrlAccountCreator } from './account_creator'; import { InMemoryKeyStore, MergeKeyStore } from './key_stores'; @@ -36,7 +36,7 @@ export class Near { return account; } - async createAccount(accountId: string, publicKey: string): Promise { + async createAccount(accountId: string, publicKey: PublicKey): Promise { if (!this.accountCreator) { throw new Error('Must specify account creator, either via masterAccount or helperUrl configuration settings.'); } diff --git a/src.ts/signer.ts b/src.ts/signer.ts index 141bd2fa98..9bf29e8619 100644 --- a/src.ts/signer.ts +++ b/src.ts/signer.ts @@ -1,7 +1,7 @@ 'use strict'; import sha256 from 'js-sha256'; -import { Signature, KeyPair } from './utils/key_pair'; +import { Signature, KeyPair, PublicKey } from './utils/key_pair'; import { KeyStore } from './key_stores'; /** @@ -12,14 +12,14 @@ export abstract class Signer { /** * Creates new key and returns public key. */ - abstract async createKey(accountId: string, networkId?: string): Promise; + abstract async createKey(accountId: string, networkId?: string): Promise; /** * Returns public key for given account / network. * @param accountId accountId to retrieve from. * @param networkId network for this accountId. */ - abstract async getPublicKey(accountId?: string, networkId?: string): Promise; + abstract async getPublicKey(accountId?: string, networkId?: string): Promise; /** * Signs given hash. @@ -51,13 +51,13 @@ export class InMemorySigner extends Signer { this.keyStore = keyStore; } - async createKey(accountId: string, networkId: string): Promise { + async createKey(accountId: string, networkId: string): Promise { const keyPair = KeyPair.fromRandom('ed25519'); await this.keyStore.setKey(networkId, accountId, keyPair); return keyPair.getPublicKey(); } - async getPublicKey(accountId?: string, networkId?: string): Promise { + async getPublicKey(accountId?: string, networkId?: string): Promise { const keyPair = await this.keyStore.getKey(networkId, accountId); return keyPair.getPublicKey(); } diff --git a/src.ts/transaction.ts b/src.ts/transaction.ts index 6a5e57b90c..ee34bad756 100644 --- a/src.ts/transaction.ts +++ b/src.ts/transaction.ts @@ -3,7 +3,8 @@ import sha256 from 'js-sha256'; import BN from 'bn.js'; -import { base_decode, serialize } from './utils/serialize'; +import { serialize } from './utils/serialize'; +import { KeyType, PublicKey } from './utils/key_pair'; import { Signer } from './signer'; class Enum { @@ -81,36 +82,22 @@ export function transfer(deposit: BN): Action { return new Action({transfer: new Transfer({ deposit }) }); } -export function stake(stake: BN, publicKey: string): Action { - return new Action({stake: new Stake({ stake, publicKey: new PublicKey(publicKey) }) }); +export function stake(stake: BN, publicKey: PublicKey): Action { + return new Action({stake: new Stake({ stake, publicKey }) }); } -export function addKey(publicKey: string, accessKey: AccessKey): Action { - return new Action({addKey: new AddKey({ publicKey: new PublicKey(publicKey), accessKey}) }); +export function addKey(publicKey: PublicKey, accessKey: AccessKey): Action { + return new Action({addKey: new AddKey({ publicKey, accessKey}) }); } -export function deleteKey(publicKey: string): Action { - return new Action({deleteKey: new DeleteKey({ publicKey: new PublicKey(publicKey) }) }); +export function deleteKey(publicKey: PublicKey): Action { + return new Action({deleteKey: new DeleteKey({ publicKey }) }); } export function deleteAccount(beneficiaryId: string): Action { return new Action({deleteAccount: new DeleteAccount({ beneficiaryId }) }); } -enum KeyType { - ED25519 = 0, -} - -class PublicKey { - keyType: KeyType; - data: Uint8Array; - - constructor(publicKey: string) { - this.keyType = KeyType.ED25519; - this.data = base_decode(publicKey); - } -} - class Signature { keyType: KeyType; data: Uint8Array; @@ -191,7 +178,7 @@ const SCHEMA = new Map([ ]); export async function signTransaction(receiverId: string, nonce: number, actions: Action[], blockHash: Uint8Array, signer: Signer, accountId?: string, networkId?: string): Promise<[Uint8Array, SignedTransaction]> { - const publicKey = new PublicKey(await signer.getPublicKey(accountId, networkId)); + const publicKey = await signer.getPublicKey(accountId, networkId); const transaction = new Transaction({ signerId: accountId, publicKey, nonce, receiverId, actions, blockHash }); const message = serialize(SCHEMA, transaction); const hash = new Uint8Array(sha256.sha256.array(message)); diff --git a/src.ts/utils/key_pair.ts b/src.ts/utils/key_pair.ts index 2eff5bf004..b54fa60245 100644 --- a/src.ts/utils/key_pair.ts +++ b/src.ts/utils/key_pair.ts @@ -7,31 +7,88 @@ export type Arrayish = string | ArrayLike; export interface Signature { signature: Uint8Array; - publicKey: string; + publicKey: PublicKey; +} + +/** All supported key types */ +export enum KeyType { + ED25519 = 0, +} + +function key_type_to_str(key_type: KeyType): String { + switch (key_type) { + case KeyType.ED25519: return 'ED25519'; + default: throw new Error(`Unknown key type ${key_type}`); + } +} + +function str_to_key_type(key_type: string): KeyType { + switch (key_type.toUpperCase()) { + case 'ED25519': return KeyType.ED25519; + default: throw new Error(`Unknown key type ${key_type}`); + } +} + +/** + * PublicKey representation that has type and bytes of the key. + */ +export class PublicKey { + keyType: KeyType; + data: Uint8Array; + + constructor(keyType: KeyType, data: Uint8Array) { + this.keyType = keyType; + this.data = data; + } + + static from(value: string | PublicKey): PublicKey { + if (typeof value === 'string') { + return PublicKey.fromString(value); + } + return value; + } + + static fromString(encodedKey: string): PublicKey { + const parts = encodedKey.split(':'); + if (parts.length == 1) { + return new PublicKey(KeyType.ED25519, base_decode(parts[0])); + } else if (parts.length == 2) { + return new PublicKey(str_to_key_type(parts[0]), base_decode(parts[1])); + } else { + throw new Error('Invlaid encoded key format, must be :'); + } + } + + toString(): string { + return `${key_type_to_str(this.keyType)}:${base_encode(this.data)}`; + } } export abstract class KeyPair { abstract sign(message: Uint8Array): Signature; abstract verify(message: Uint8Array, signature: Uint8Array): boolean; abstract toString(): string; - abstract getPublicKey(): string; + abstract getPublicKey(): PublicKey; static fromRandom(curve: string): KeyPair { - switch (curve) { - case 'ed25519': return KeyPairEd25519.fromRandom(); + switch (curve.toUpperCase()) { + case 'ED25519': return KeyPairEd25519.fromRandom(); default: throw new Error(`Unknown curve ${curve}`); } } static fromString(encodedKey: string): KeyPair { const parts = encodedKey.split(':'); - if (parts.length !== 2) { + if (parts.length == 1) { + return new KeyPairEd25519(parts[0]); + } else if (parts.length == 2) { + switch (parts[0].toUpperCase()) { + case 'ED25519': return new KeyPairEd25519(parts[1]); + default: throw new Error(`Unknown curve: ${parts[0]}`); + } + } else { 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]}`); - } } } @@ -40,7 +97,7 @@ export abstract class KeyPair { * generating key pairs, encoding key pairs, signing and verifying. */ export class KeyPairEd25519 extends KeyPair { - readonly publicKey: string; + readonly publicKey: PublicKey; readonly secretKey: string; /** @@ -51,7 +108,7 @@ export class KeyPairEd25519 extends KeyPair { constructor(secretKey: string) { super(); const keyPair = nacl.sign.keyPair.fromSecretKey(base_decode(secretKey)); - this.publicKey = base_encode(keyPair.publicKey); + this.publicKey = new PublicKey(KeyType.ED25519, keyPair.publicKey); this.secretKey = secretKey; } @@ -76,14 +133,14 @@ export class KeyPairEd25519 extends KeyPair { } verify(message: Uint8Array, signature: Uint8Array): boolean { - return nacl.sign.detached.verify(message, signature, base_decode(this.publicKey)); + return nacl.sign.detached.verify(message, signature, this.publicKey.data); } toString(): string { return `ed25519:${this.secretKey}`; } - getPublicKey(): string { + getPublicKey(): PublicKey { return this.publicKey; } } diff --git a/src.ts/wallet-account.ts b/src.ts/wallet-account.ts index b3ed09066b..34b89d302b 100644 --- a/src.ts/wallet-account.ts +++ b/src.ts/wallet-account.ts @@ -73,7 +73,7 @@ export class WalletAccount { newUrl.searchParams.set('failure_url', failureUrl || currentUrl.href); newUrl.searchParams.set('app_url', currentUrl.origin); const accessKey = KeyPair.fromRandom('ed25519'); - newUrl.searchParams.set('public_key', accessKey.getPublicKey()); + newUrl.searchParams.set('public_key', accessKey.getPublicKey().toString()); await this._keyStore.setKey(this._networkId, PENDING_ACCESS_KEY_PREFIX + accessKey.getPublicKey(), accessKey); window.location.assign(newUrl.toString()); } diff --git a/test/key_pair.test.js b/test/key_pair.test.js index 7b18ca46b5..7ed0a90026 100644 --- a/test/key_pair.test.js +++ b/test/key_pair.test.js @@ -4,7 +4,7 @@ const { sha256 } = require('js-sha256'); test('test sign and verify', async () => { const keyPair = new nearlib.utils.key_pair.KeyPairEd25519('26x56YPzPDro5t2smQfGcYAPy3j7R2jB2NUb7xKbAGK23B6x4WNQPh3twb6oDksFov5X8ts5CtntUNbpQpAKFdbR'); - expect(keyPair.publicKey).toEqual('AYWv9RAN1hpSQA4p1DLhCNnpnNXwxhfH9qeHN8B4nJ59'); + expect(keyPair.publicKey.toString()).toEqual('ED25519:AYWv9RAN1hpSQA4p1DLhCNnpnNXwxhfH9qeHN8B4nJ59'); const message = new Uint8Array(sha256.array('message')); const signature = keyPair.sign(message); expect(nearlib.utils.serialize.base_encode(signature.signature)).toEqual('26gFr4xth7W9K7HPWAxq3BLsua8oTy378mC1MYFiEXHBBpeBjP8WmJEJo8XTBowetvqbRshcQEtBUdwQcAqDyP8T'); @@ -19,7 +19,7 @@ test('test sign and verify with random', async () => { test('test from secret', async () => { const keyPair = new nearlib.utils.key_pair.KeyPairEd25519('5JueXZhEEVqGVT5powZ5twyPP8wrap2K7RdAYGGdjBwiBdd7Hh6aQxMP1u3Ma9Yanq1nEv32EW7u8kUJsZ6f315C'); - expect(keyPair.publicKey).toEqual('EWrekY1deMND7N3Q7Dixxj12wD7AVjFRt2H9q21QHUSW'); + expect(keyPair.publicKey.toString()).toEqual('ED25519:EWrekY1deMND7N3Q7Dixxj12wD7AVjFRt2H9q21QHUSW'); }); test('convert to string', async () => {