diff --git a/lib/account.js b/lib/account.js index 2d58fe4746..957a863f7b 100644 --- a/lib/account.js +++ b/lib/account.js @@ -19,13 +19,13 @@ function sleep(millis) { return new Promise(resolve => setTimeout(resolve, millis)); } class Account { - get ready() { - return this._ready || (this._ready = Promise.resolve(this.fetchState())); - } constructor(connection, accountId) { this.connection = connection; this.accountId = accountId; } + get ready() { + return this._ready || (this._ready = Promise.resolve(this.fetchState())); + } async fetchState() { this._state = await this.connection.provider.query(`account/${this.accountId}`, ''); try { @@ -67,7 +67,7 @@ class Account { if (this._accessKey === null) { throw new Error(`Can not sign transactions, initialize account with available public key in Signer.`); } - let status = await this.connection.provider.status(); + const 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 { diff --git a/lib/utils/key_pair.js b/lib/utils/key_pair.js index 1fd1a30c8c..ea9bb75b79 100644 --- a/lib/utils/key_pair.js +++ b/lib/utils/key_pair.js @@ -10,16 +10,16 @@ var KeyType; (function (KeyType) { KeyType[KeyType["ED25519"] = 0] = "ED25519"; })(KeyType = exports.KeyType || (exports.KeyType = {})); -function key_type_to_str(key_type) { - switch (key_type) { +function key_type_to_str(keyType) { + switch (keyType) { case KeyType.ED25519: return 'ed25519'; - default: throw new Error(`Unknown key type ${key_type}`); + default: throw new Error(`Unknown key type ${keyType}`); } } -function str_to_key_type(key_type) { - switch (key_type.toLowerCase()) { +function str_to_key_type(keyType) { + switch (keyType.toLowerCase()) { case 'ed25519': return KeyType.ED25519; - default: throw new Error(`Unknown key type ${key_type}`); + default: throw new Error(`Unknown key type ${keyType}`); } } /** @@ -38,10 +38,10 @@ class PublicKey { } static fromString(encodedKey) { const parts = encodedKey.split(':'); - if (parts.length == 1) { + if (parts.length === 1) { return new PublicKey(KeyType.ED25519, serialize_1.base_decode(parts[0])); } - else if (parts.length == 2) { + else if (parts.length === 2) { return new PublicKey(str_to_key_type(parts[0]), serialize_1.base_decode(parts[1])); } else { @@ -62,10 +62,10 @@ class KeyPair { } static fromString(encodedKey) { const parts = encodedKey.split(':'); - if (parts.length == 1) { + if (parts.length === 1) { return new KeyPairEd25519(parts[0]); } - else if (parts.length == 2) { + else if (parts.length === 2) { switch (parts[0].toUpperCase()) { case 'ED25519': return new KeyPairEd25519(parts[1]); default: throw new Error(`Unknown curve: ${parts[0]}`); diff --git a/test/config.js b/test/config.js index 72760f0910..791edd0ad7 100644 --- a/test/config.js +++ b/test/config.js @@ -1,38 +1,38 @@ module.exports = function getConfig(env) { switch (env) { - case 'production': - case 'development': - return { - networkId: 'default', - nodeUrl: 'http://34.94.33.164:3030', - masterAccount: 'test.near', - }; - case 'local': - return { - networkId: 'local', - nodeUrl: 'http://localhost:3030', - keyPath: `${process.env.HOME}/.near/validator_key.json`, - }; - case 'test': - return { - networkId: 'local', - nodeUrl: 'http://localhost:3030', - masterAccount: 'test.near', - }; - case 'test-remote': - case 'ci': - return { - networkId: 'shared-test', - nodeUrl: 'http://shared-test.nearprotocol.com:3030', - masterAccount: 'test.near', - }; - case 'ci-staging': - return { - networkId: 'shared-test-staging', - nodeUrl: 'http://staging-shared-test.nearprotocol.com:3030', - masterAccount: 'test.near', - }; - default: - throw Error(`Unconfigured environment '${env}'. Can be configured in test/config.js.`); + case 'production': + case 'development': + return { + networkId: 'default', + nodeUrl: 'http://34.94.33.164:3030', + masterAccount: 'test.near', + }; + case 'local': + return { + networkId: 'local', + nodeUrl: 'http://localhost:3030', + keyPath: `${process.env.HOME}/.near/validator_key.json`, + }; + case 'test': + return { + networkId: 'local', + nodeUrl: 'http://localhost:3030', + masterAccount: 'test.near', + }; + case 'test-remote': + case 'ci': + return { + networkId: 'shared-test', + nodeUrl: 'http://shared-test.nearprotocol.com:3030', + masterAccount: 'test.near', + }; + case 'ci-staging': + return { + networkId: 'shared-test-staging', + nodeUrl: 'http://staging-shared-test.nearprotocol.com:3030', + masterAccount: 'test.near', + }; + default: + throw Error(`Unconfigured environment '${env}'. Can be configured in test/config.js.`); } };