near-api-js 6.4.0 → 6.4.1

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.
@@ -1,6 +1,6 @@
1
1
  export { b as keyStores } from './browser-index-RhYalP0h.js';
2
2
  export { i as providers } from './index-BDdRUK93.js';
3
- export { i as utils } from './index-B3Nnuq00.js';
3
+ export { i as utils } from './index-CIVdT9gH.js';
4
4
  export { t as transactions } from './transaction-C81hWIM7.js';
5
5
  export { v as validators } from './validators-q97R8D1k.js';
6
6
  export { Account, Connection, Contract } from '@near-js/accounts';
@@ -1,5 +1,5 @@
1
1
  export { i as providers } from './index-BDdRUK93.js';
2
- export { i as utils } from './index-B3Nnuq00.js';
2
+ export { i as utils } from './index-CIVdT9gH.js';
3
3
  export { t as transactions } from './transaction-C81hWIM7.js';
4
4
  export { v as validators } from './validators-q97R8D1k.js';
5
5
  export { Account, Connection, Contract } from '@near-js/accounts';
@@ -3,7 +3,7 @@ import { s as serialize } from './serialize-DKM2UWTl.js';
3
3
  import { e as enums } from './enums-BOxGXwY_.js';
4
4
  import { f as format } from './format-BlG-d3wc.js';
5
5
  import { r as rpc_errors } from './rpc_errors-BbA15mFX.js';
6
- import { Logger } from '@near-js/utils';
6
+ import { Logger, keyToImplicitAddress } from '@near-js/utils';
7
7
  import { KeyPair, KeyPairEd25519, KeyPairString, PublicKey } from '@near-js/crypto';
8
8
 
9
9
  declare const index_KeyPair: typeof KeyPair;
@@ -13,11 +13,12 @@ declare const index_Logger: typeof Logger;
13
13
  declare const index_PublicKey: typeof PublicKey;
14
14
  declare const index_enums: typeof enums;
15
15
  declare const index_format: typeof format;
16
+ declare const index_keyToImplicitAddress: typeof keyToImplicitAddress;
16
17
  declare const index_key_pair: typeof key_pair;
17
18
  declare const index_rpc_errors: typeof rpc_errors;
18
19
  declare const index_serialize: typeof serialize;
19
20
  declare namespace index {
20
- export { index_KeyPair as KeyPair, index_KeyPairEd25519 as KeyPairEd25519, index_KeyPairString as KeyPairString, index_Logger as Logger, index_PublicKey as PublicKey, index_enums as enums, index_format as format, index_key_pair as key_pair, index_rpc_errors as rpc_errors, index_serialize as serialize };
21
+ export { index_KeyPair as KeyPair, index_KeyPairEd25519 as KeyPairEd25519, index_KeyPairString as KeyPairString, index_Logger as Logger, index_PublicKey as PublicKey, index_enums as enums, index_format as format, index_keyToImplicitAddress as keyToImplicitAddress, index_key_pair as key_pair, index_rpc_errors as rpc_errors, index_serialize as serialize };
21
22
  }
22
23
 
23
24
  export { index as i };
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { i as keyStores } from './index-Dvb6OQET.js';
2
2
  export { i as providers } from './index-BDdRUK93.js';
3
- export { i as utils } from './index-B3Nnuq00.js';
3
+ export { i as utils } from './index-CIVdT9gH.js';
4
4
  export { t as transactions } from './transaction-C81hWIM7.js';
5
5
  export { v as validators } from './validators-q97R8D1k.js';
6
6
  export { Account, Connection, Contract } from '@near-js/accounts';
package/lib/near.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Connection, AccountCreator, Account } from '@near-js/accounts';
2
2
  import { PublicKey } from '@near-js/crypto';
3
3
  import { KeyStore } from '@near-js/keystores';
4
- import { Signer } from '@near-js/signers';
4
+ import { InMemorySigner } from '@near-js/signers';
5
5
  import { LoggerService } from '@near-js/utils';
6
6
  import { Provider } from '@near-js/providers';
7
7
 
@@ -20,7 +20,7 @@ interface NearConfig {
20
20
  /** Holds {@link "@near-js/crypto".key_pair.KeyPair | KeyPair} for signing transactions */
21
21
  keyStore?: KeyStore;
22
22
  /** @hidden */
23
- signer?: Signer;
23
+ signer?: InMemorySigner;
24
24
  /**
25
25
  * [NEAR Contract Helper](https://github.com/near/near-contract-helper) url used to create accounts if no master account is provided
26
26
  * @see {@link UrlAccountCreator}
@@ -89,6 +89,7 @@ declare class Near {
89
89
  readonly connection: Connection;
90
90
  readonly accountCreator: AccountCreator;
91
91
  constructor(config: NearConfig);
92
+ private resolveKeyPairSigner;
92
93
  /**
93
94
  * @param accountId near accountId used to interact with the network.
94
95
  */
package/lib/near.js CHANGED
@@ -32,6 +32,7 @@ __export(near_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(near_exports);
34
34
  var import_accounts = require("@near-js/accounts");
35
+ var import_signers = require("@near-js/signers");
35
36
  var import_depd = __toESM(require("depd"));
36
37
  class Near {
37
38
  constructor(config) {
@@ -45,18 +46,24 @@ class Near {
45
46
  });
46
47
  if (config.masterAccount) {
47
48
  const initialBalance = config.initialBalance ? BigInt(config.initialBalance) : 500000000000000000000000000n;
48
- this.accountCreator = new import_accounts.LocalAccountCreator(new import_accounts.Account(config.masterAccount, this.connection.provider, this.connection.signer), initialBalance);
49
+ const account = new import_accounts.Account(config.masterAccount, this.connection.provider);
50
+ this.resolveKeyPairSigner(config.masterAccount).then((signer) => account.setSigner(signer));
51
+ this.accountCreator = new import_accounts.LocalAccountCreator(account, initialBalance);
49
52
  } else if (config.helperUrl) {
50
53
  this.accountCreator = new import_accounts.UrlAccountCreator(this.connection, config.helperUrl);
51
54
  } else {
52
55
  this.accountCreator = null;
53
56
  }
54
57
  }
58
+ async resolveKeyPairSigner(accountId) {
59
+ const keyPair = await this.connection.signer.keyStore.getKey(this.connection.networkId, accountId);
60
+ return keyPair ? new import_signers.KeyPairSigner(keyPair) : void 0;
61
+ }
55
62
  /**
56
63
  * @param accountId near accountId used to interact with the network.
57
64
  */
58
65
  async account(accountId) {
59
- const account = new import_accounts.Account(accountId, this.connection.provider, this.connection.signer);
66
+ const account = new import_accounts.Account(accountId, this.connection.provider, await this.resolveKeyPairSigner(accountId));
60
67
  return account;
61
68
  }
62
69
  /**
@@ -73,7 +80,7 @@ class Near {
73
80
  throw new Error("Must specify account creator, either via masterAccount or helperUrl configuration settings.");
74
81
  }
75
82
  await this.accountCreator.createAccount(accountId, publicKey);
76
- return new import_accounts.Account(accountId, this.connection.provider, this.connection.signer);
83
+ return new import_accounts.Account(accountId, this.connection.provider, await this.resolveKeyPairSigner(accountId));
77
84
  }
78
85
  }
79
86
  // Annotate the CommonJS export names for ESM import in node:
@@ -3,7 +3,7 @@ export { s as serialize } from '../serialize-DKM2UWTl.js';
3
3
  export { e as enums } from '../enums-BOxGXwY_.js';
4
4
  export { f as format } from '../format-BlG-d3wc.js';
5
5
  export { r as rpc_errors } from '../rpc_errors-BbA15mFX.js';
6
- export { Logger } from '@near-js/utils';
6
+ export { Logger, keyToImplicitAddress } from '@near-js/utils';
7
7
  export { KeyPair, KeyPairEd25519, KeyPairString, PublicKey } from '@near-js/crypto';
8
8
  import 'borsh';
9
9
  import '@near-js/types';
@@ -35,6 +35,7 @@ __export(utils_exports, {
35
35
  PublicKey: () => import_key_pair.PublicKey,
36
36
  enums: () => enums,
37
37
  format: () => format,
38
+ keyToImplicitAddress: () => import_utils.keyToImplicitAddress,
38
39
  key_pair: () => key_pair,
39
40
  rpc_errors: () => rpc_errors,
40
41
  serialize: () => serialize
@@ -47,6 +48,7 @@ var format = __toESM(require('./format.js'));
47
48
  var rpc_errors = __toESM(require('./rpc_errors.js'));
48
49
  var import_key_pair = require('./key_pair.js');
49
50
  var import_logger = require('./logger.js');
51
+ var import_utils = require("@near-js/utils");
50
52
  // Annotate the CommonJS export names for ESM import in node:
51
53
  0 && (module.exports = {
52
54
  KeyPair,
@@ -56,6 +58,7 @@ var import_logger = require('./logger.js');
56
58
  PublicKey,
57
59
  enums,
58
60
  format,
61
+ keyToImplicitAddress,
59
62
  key_pair,
60
63
  rpc_errors,
61
64
  serialize
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": "6.4.0",
4
+ "version": "6.4.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/near/near-api-js.git"
@@ -17,16 +17,16 @@
17
17
  "http-errors": "1.7.2",
18
18
  "near-abi": "0.2.0",
19
19
  "node-fetch": "2.6.7",
20
- "@near-js/accounts": "2.4.0",
21
- "@near-js/crypto": "2.4.0",
22
- "@near-js/keystores": "2.4.0",
23
- "@near-js/keystores-browser": "2.4.0",
24
- "@near-js/keystores-node": "2.4.0",
25
- "@near-js/providers": "2.4.0",
26
- "@near-js/signers": "2.4.0",
27
- "@near-js/transactions": "2.4.0",
28
- "@near-js/types": "2.4.0",
29
- "@near-js/utils": "2.4.0"
20
+ "@near-js/accounts": "2.4.1",
21
+ "@near-js/crypto": "2.4.1",
22
+ "@near-js/keystores": "2.4.1",
23
+ "@near-js/keystores-browser": "2.4.1",
24
+ "@near-js/keystores-node": "2.4.1",
25
+ "@near-js/providers": "2.4.1",
26
+ "@near-js/signers": "2.4.1",
27
+ "@near-js/transactions": "2.4.1",
28
+ "@near-js/types": "2.4.1",
29
+ "@near-js/utils": "2.4.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/depd": "^1.1.37",