create-near-app 6.4.3 → 6.4.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-near-app",
3
- "version": "6.4.3",
3
+ "version": "6.4.4",
4
4
  "description": "Quickly scaffold your dApp on NEAR Blockchain",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
 
3
2
  // near api js
4
3
  import { providers } from 'near-api-js';
@@ -24,13 +23,8 @@ export class Wallet {
24
23
  * wallet.startUp((signedAccountId) => console.log(signedAccountId));
25
24
  */
26
25
  constructor({ networkId = 'testnet', createAccessKeyFor = undefined }) {
27
- this.accountId = '';
28
26
  this.createAccessKeyFor = createAccessKeyFor;
29
-
30
- this.selector = setupWalletSelector({
31
- network: networkId,
32
- modules: [setupMyNearWallet(), setupHereWallet()]
33
- });
27
+ this.networkId = networkId;
34
28
  }
35
29
 
36
30
  /**
@@ -39,13 +33,14 @@ export class Wallet {
39
33
  * @returns {Promise<string>} - the accountId of the signed-in user
40
34
  */
41
35
  startUp = async (accountChangeHook) => {
36
+ this.selector = setupWalletSelector({
37
+ network: this.networkId,
38
+ modules: [setupMyNearWallet(), setupHereWallet()]
39
+ });
40
+
42
41
  const walletSelector = await this.selector;
43
42
  const isSignedIn = walletSelector.isSignedIn();
44
-
45
- if (isSignedIn) {
46
- this.accountId = walletSelector.store.getState().accounts[0].accountId;
47
- this.selectedWallet = await walletSelector.wallet();
48
- }
43
+ const accountId = isSignedIn ? walletSelector.store.getState().accounts[0].accountId : '';
49
44
 
50
45
  walletSelector.store.observable
51
46
  .pipe(
@@ -57,7 +52,7 @@ export class Wallet {
57
52
  accountChangeHook(signedAccount);
58
53
  });
59
54
 
60
- return this.accountId;
55
+ return accountId;
61
56
  };
62
57
 
63
58
  /**
@@ -72,8 +67,8 @@ export class Wallet {
72
67
  * Logout the user
73
68
  */
74
69
  signOut = async () => {
75
- await this.selectedWallet.signOut();
76
- this.selectedWallet = this.accountId = this.createAccessKeyFor = null;
70
+ const selectedWallet = await (await this.selector).wallet();
71
+ selectedWallet.signOut();
77
72
  };
78
73
 
79
74
  /**
@@ -110,8 +105,8 @@ export class Wallet {
110
105
  */
111
106
  callMethod = async ({ contractId, method, args = {}, gas = THIRTY_TGAS, deposit = NO_DEPOSIT }) => {
112
107
  // Sign a transaction with the "FunctionCall" action
113
- return await this.selectedWallet.signAndSendTransaction({
114
- signerId: this.accountId,
108
+ const selectedWallet = await (await this.selector).wallet();
109
+ const outcome = await selectedWallet.signAndSendTransaction({
115
110
  receiverId: contractId,
116
111
  actions: [
117
112
  {
@@ -125,6 +120,8 @@ export class Wallet {
125
120
  },
126
121
  ],
127
122
  });
123
+
124
+ return providers.getTransactionLastResult(outcome);
128
125
  };
129
126
 
130
127
  /**
@@ -23,13 +23,8 @@ export class Wallet {
23
23
  * wallet.startUp((signedAccountId) => console.log(signedAccountId));
24
24
  */
25
25
  constructor({ networkId = 'testnet', createAccessKeyFor = undefined }) {
26
- this.accountId = '';
27
26
  this.createAccessKeyFor = createAccessKeyFor;
28
-
29
- this.selector = setupWalletSelector({
30
- network: networkId,
31
- modules: [setupMyNearWallet(), setupHereWallet()]
32
- });
27
+ this.networkId = networkId;
33
28
  }
34
29
 
35
30
  /**
@@ -38,13 +33,14 @@ export class Wallet {
38
33
  * @returns {Promise<string>} - the accountId of the signed-in user
39
34
  */
40
35
  startUp = async (accountChangeHook) => {
36
+ this.selector = setupWalletSelector({
37
+ network: this.networkId,
38
+ modules: [setupMyNearWallet(), setupHereWallet()]
39
+ });
40
+
41
41
  const walletSelector = await this.selector;
42
42
  const isSignedIn = walletSelector.isSignedIn();
43
-
44
- if (isSignedIn) {
45
- this.accountId = walletSelector.store.getState().accounts[0].accountId;
46
- this.selectedWallet = await walletSelector.wallet();
47
- }
43
+ const accountId = isSignedIn ? walletSelector.store.getState().accounts[0].accountId : '';
48
44
 
49
45
  walletSelector.store.observable
50
46
  .pipe(
@@ -56,7 +52,7 @@ export class Wallet {
56
52
  accountChangeHook(signedAccount);
57
53
  });
58
54
 
59
- return this.accountId;
55
+ return accountId;
60
56
  };
61
57
 
62
58
  /**
@@ -71,8 +67,8 @@ export class Wallet {
71
67
  * Logout the user
72
68
  */
73
69
  signOut = async () => {
74
- await this.selectedWallet.signOut();
75
- this.selectedWallet = this.accountId = this.createAccessKeyFor = null;
70
+ const selectedWallet = await (await this.selector).wallet();
71
+ selectedWallet.signOut();
76
72
  };
77
73
 
78
74
  /**
@@ -109,8 +105,8 @@ export class Wallet {
109
105
  */
110
106
  callMethod = async ({ contractId, method, args = {}, gas = THIRTY_TGAS, deposit = NO_DEPOSIT }) => {
111
107
  // Sign a transaction with the "FunctionCall" action
112
- return await this.selectedWallet.signAndSendTransaction({
113
- signerId: this.accountId,
108
+ const selectedWallet = await (await this.selector).wallet();
109
+ const outcome = await selectedWallet.signAndSendTransaction({
114
110
  receiverId: contractId,
115
111
  actions: [
116
112
  {
@@ -124,6 +120,8 @@ export class Wallet {
124
120
  },
125
121
  ],
126
122
  });
123
+
124
+ return providers.getTransactionLastResult(outcome);
127
125
  };
128
126
 
129
127
  /**