near-api-js 2.1.1 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24766,11 +24766,12 @@ const bn_js_1 = __importDefault(require("bn.js"));
24766
24766
  */
24767
24767
  class Near {
24768
24768
  constructor(config) {
24769
+ var _a;
24769
24770
  this.config = config;
24770
24771
  this.connection = accounts_1.Connection.fromConfig({
24771
24772
  networkId: config.networkId,
24772
24773
  provider: { type: 'JsonRpcProvider', args: { url: config.nodeUrl, headers: config.headers } },
24773
- signer: config.signer || { type: 'InMemorySigner', keyStore: config.keyStore },
24774
+ signer: config.signer || { type: 'InMemorySigner', keyStore: config.keyStore || ((_a = config.deps) === null || _a === void 0 ? void 0 : _a.keyStore) },
24774
24775
  jsvmAccountId: config.jsvmAccountId || `jsvm.${config.networkId}`
24775
24776
  });
24776
24777
  if (config.masterAccount) {
@@ -1913,7 +1913,7 @@ module.exports={
1913
1913
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WalletConnection=exports.ConnectedWalletAccount=exports.Near=void 0;var near_1=require("./near");Object.defineProperty(exports,"Near",{enumerable:!0,get:function(){return near_1.Near}});var wallet_account_1=require("./wallet_account");Object.defineProperty(exports,"ConnectedWalletAccount",{enumerable:!0,get:function(){return wallet_account_1.ConnectedWalletAccount}}),Object.defineProperty(exports,"WalletConnection",{enumerable:!0,get:function(){return wallet_account_1.WalletConnection}});
1914
1914
 
1915
1915
  },{"./near":235,"./wallet_account":236}],235:[function(require,module,exports){
1916
- "use strict";var __awaiter=this&&this.__awaiter||function(t,n,e,o){return new(e||(e=Promise))(function(c,r){function i(t){try{s(o.next(t))}catch(t){r(t)}}function a(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var n;t.done?c(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(i,a)}s((o=o.apply(t,n||[])).next())})},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Near=void 0;const accounts_1=require("@near-js/accounts"),bn_js_1=__importDefault(require("bn.js"));class Near{constructor(t){if(this.config=t,this.connection=accounts_1.Connection.fromConfig({networkId:t.networkId,provider:{type:"JsonRpcProvider",args:{url:t.nodeUrl,headers:t.headers}},signer:t.signer||{type:"InMemorySigner",keyStore:t.keyStore},jsvmAccountId:t.jsvmAccountId||`jsvm.${t.networkId}`}),t.masterAccount){const n=t.initialBalance?new bn_js_1.default(t.initialBalance):new bn_js_1.default("500000000000000000000000000");this.accountCreator=new accounts_1.LocalAccountCreator(new accounts_1.Account(this.connection,t.masterAccount),n)}else t.helperUrl?this.accountCreator=new accounts_1.UrlAccountCreator(this.connection,t.helperUrl):this.accountCreator=null}account(t){return __awaiter(this,void 0,void 0,function*(){return new accounts_1.Account(this.connection,t)})}createAccount(t,n){return __awaiter(this,void 0,void 0,function*(){if(!this.accountCreator)throw new Error("Must specify account creator, either via masterAccount or helperUrl configuration settings.");return yield this.accountCreator.createAccount(t,n),new accounts_1.Account(this.connection,t)})}}exports.Near=Near;
1916
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))(function(r,c){function i(t){try{s(o.next(t))}catch(t){c(t)}}function a(t){try{s(o.throw(t))}catch(t){c(t)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,a)}s((o=o.apply(t,e||[])).next())})},__importDefault=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.Near=void 0;const accounts_1=require("@near-js/accounts"),bn_js_1=__importDefault(require("bn.js"));class Near{constructor(t){var e;if(this.config=t,this.connection=accounts_1.Connection.fromConfig({networkId:t.networkId,provider:{type:"JsonRpcProvider",args:{url:t.nodeUrl,headers:t.headers}},signer:t.signer||{type:"InMemorySigner",keyStore:t.keyStore||(null===(e=t.deps)||void 0===e?void 0:e.keyStore)},jsvmAccountId:t.jsvmAccountId||`jsvm.${t.networkId}`}),t.masterAccount){const e=t.initialBalance?new bn_js_1.default(t.initialBalance):new bn_js_1.default("500000000000000000000000000");this.accountCreator=new accounts_1.LocalAccountCreator(new accounts_1.Account(this.connection,t.masterAccount),e)}else t.helperUrl?this.accountCreator=new accounts_1.UrlAccountCreator(this.connection,t.helperUrl):this.accountCreator=null}account(t){return __awaiter(this,void 0,void 0,function*(){return new accounts_1.Account(this.connection,t)})}createAccount(t,e){return __awaiter(this,void 0,void 0,function*(){if(!this.accountCreator)throw new Error("Must specify account creator, either via masterAccount or helperUrl configuration settings.");return yield this.accountCreator.createAccount(t,e),new accounts_1.Account(this.connection,t)})}}exports.Near=Near;
1917
1917
 
1918
1918
  },{"@near-js/accounts":155,"bn.js":69}],236:[function(require,module,exports){
1919
1919
  (function (Buffer){(function (){
package/lib/connect.js CHANGED
@@ -21,6 +21,7 @@ exports.connect = void 0;
21
21
  * To sign transactions you can also pass:
22
22
  * 1. {@link ConnectConfig.keyStore}
23
23
  * 2. {@link ConnectConfig.keyPath}
24
+ * 3. {@link ConnectConfig.deps.keyStore} (deprecated, only for use in legacy applications)
24
25
  *
25
26
  * If all three are passed they are prioritize in that order.
26
27
  *
@@ -46,9 +47,10 @@ global.fetch = setup_node_fetch_1.default;
46
47
  * Initialize connection to Near network.
47
48
  */
48
49
  function connect(config) {
50
+ var _a, _b;
49
51
  return __awaiter(this, void 0, void 0, function* () {
50
52
  // Try to find extra key in `KeyPath` if provided.
51
- if (config.keyPath && config.keyStore) {
53
+ if (config.keyPath && (config.keyStore || ((_a = config.deps) === null || _a === void 0 ? void 0 : _a.keyStore))) {
52
54
  try {
53
55
  const accountKeyFile = yield (0, unencrypted_file_system_keystore_1.readKeyFile)(config.keyPath);
54
56
  if (accountKeyFile[0]) {
@@ -61,7 +63,7 @@ function connect(config) {
61
63
  }
62
64
  config.keyStore = new key_stores_1.MergeKeyStore([
63
65
  keyPathStore,
64
- config.keyStore
66
+ config.keyStore || ((_b = config.deps) === null || _b === void 0 ? void 0 : _b.keyStore)
65
67
  ], { writeKeyStoreIndex: 1 });
66
68
  if (!process.env['NEAR_NO_LOGS']) {
67
69
  console.log(`Loaded master account ${accountKeyFile[0]} key from ${config.keyPath} with public key = ${keyPair.getPublicKey()}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "near-api-js",
3
3
  "description": "JavaScript library to interact with NEAR Protocol via RPC API",
4
- "version": "2.1.1",
4
+ "version": "2.1.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/near/near-api-js.git"
@@ -21,17 +21,17 @@
21
21
  "near-abi": "0.1.1",
22
22
  "node-fetch": "^2.6.1",
23
23
  "tweetnacl": "^1.0.1",
24
- "@near-js/accounts": "0.1.1",
25
- "@near-js/crypto": "0.0.3",
26
- "@near-js/keystores": "0.0.3",
27
- "@near-js/keystores-browser": "0.0.3",
28
- "@near-js/keystores-node": "0.0.3",
29
- "@near-js/providers": "0.0.4",
30
- "@near-js/signers": "0.0.3",
31
- "@near-js/transactions": "0.1.0",
32
- "@near-js/types": "0.0.3",
33
- "@near-js/utils": "0.0.3",
34
- "@near-js/wallet-account": "0.0.4"
24
+ "@near-js/accounts": "0.1.2",
25
+ "@near-js/crypto": "0.0.4",
26
+ "@near-js/keystores": "0.0.4",
27
+ "@near-js/keystores-browser": "0.0.4",
28
+ "@near-js/keystores-node": "0.0.4",
29
+ "@near-js/providers": "0.0.5",
30
+ "@near-js/signers": "0.0.4",
31
+ "@near-js/transactions": "0.1.1",
32
+ "@near-js/types": "0.0.4",
33
+ "@near-js/utils": "0.0.4",
34
+ "@near-js/wallet-account": "0.0.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/bn.js": "^5.1.0",