@massalabs/wallet-provider 1.0.0 → 1.0.1-dev.20230727122300

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/bundle.js CHANGED
@@ -118,8 +118,8 @@ class Account {
118
118
  /**
119
119
  * This method aims to transfer MAS on behalf of the sender to a recipient.
120
120
  *
121
- * @param amount - The amount of MAS to be transferred.
122
- * @param fee - The fee to be paid for the transaction execution by the node..
121
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
122
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
123
123
  * @returns An ITransactionDetails object. It contains the operationId on the network.
124
124
  */
125
125
  async sendTransaction(amount, recipientAddress, fee) {
@@ -136,20 +136,26 @@ class Account {
136
136
  });
137
137
  }
138
138
  /**
139
- * This method aims to interact with a smart contract deployed on the massa blockchain on behalf of the sender.
139
+ * This method aims to interact with a smart contract deployed on the MASSA blockchain.
140
+ *
141
+ * @remarks
142
+ * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
143
+ * IContractReadOperationResponse object which contains all the information about the dry run
144
+ * (state changes, gas used, etc.)
140
145
  *
141
146
  * @param contractAddress - The address of the smart contract.
142
147
  * @param functionName - The name of the function to be called.
143
148
  * @param parameter - The parameters as an Args object to be passed to the function.
144
- * @param amount - The amount of MASSA coins to be sent to the block creator.
149
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
150
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
151
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
152
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
153
+ *
154
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
155
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
145
156
  *
146
- * @returns An ITransactionDetails object.
147
- * - It contains the first event emitted by the contract.
148
- * - If the contract does not emit any event, it contains "Function called successfully but no event generated"
149
157
  */
150
- async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
151
- isNPE: false,
152
- }) {
158
+ async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
153
159
  return new Promise((resolve, reject) => {
154
160
  Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountCallSC, {
155
161
  nickname: this._name,
@@ -157,11 +163,13 @@ class Account {
157
163
  at: contractAddress,
158
164
  args: parameter,
159
165
  coins: amount,
166
+ fee: fee,
167
+ maxGas: maxGas,
160
168
  nonPersistentExecution: nonPersistentExecution,
161
169
  }, (result, err) => {
162
170
  if (err)
163
171
  return reject(err);
164
- return resolve(nonPersistentExecution?.isNPE
172
+ return resolve(nonPersistentExecution
165
173
  ? result
166
174
  : result);
167
175
  });
@@ -595,12 +603,29 @@ class MassaStationAccount {
595
603
  /**
596
604
  * This method aims to transfer MAS on behalf of the sender to a recipient.
597
605
  *
598
- * @param amount - The amount of MAS to be transferred.
599
- * @param fee - The fee to be paid for the transaction execution by the node.
606
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
607
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
600
608
  * @returns An ITransactionDetails object. It contains the operationId on the network.
601
609
  */
602
- sendTransaction(amount, recipientAddress, fee) {
603
- throw new Error('Method not implemented.');
610
+ async sendTransaction(amount, recipientAddress, fee) {
611
+ let sendTxOpResponse = null;
612
+ const url = `${MassaStationProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/transfer`;
613
+ const body = {
614
+ fee: fee.toString(),
615
+ amount: amount.toString(),
616
+ recipientAddress: recipientAddress,
617
+ };
618
+ try {
619
+ sendTxOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
620
+ }
621
+ catch (ex) {
622
+ console.error(`MassaStation account: error while sending transaction: ${ex}`);
623
+ throw ex;
624
+ }
625
+ if (sendTxOpResponse.isError || sendTxOpResponse.error) {
626
+ throw sendTxOpResponse.error;
627
+ }
628
+ return sendTxOpResponse.result;
604
629
  }
605
630
  /**
606
631
  * This method aims to interact with a smart contract deployed on the MASSA blockchain.
@@ -613,19 +638,18 @@ class MassaStationAccount {
613
638
  * @param contractAddress - The address of the smart contract.
614
639
  * @param functionName - The name of the function to be called.
615
640
  * @param parameter - The parameters as an Args object to be passed to the function.
616
- * @param amount - The amount of MASSA coins to be sent to the block creator.
617
- * @param dryRun - The dryRun object to be passed to the function.
641
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
642
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
643
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
644
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
618
645
  *
619
- * @returns if dryRun.dryRun is true, it returns an IContractReadOperationResponse object. Otherwise,
620
- * it returns an ITransactionDetails object which contains the first event emitted by the contract.
621
- * If the contract does not emit any event, it returns "Function called successfully but no event generated"
646
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
647
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
622
648
  *
623
649
  */
624
- async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
625
- isNPE: false,
626
- }) {
627
- if (nonPersistentExecution?.isNPE) {
628
- return this.nonPersistentCallSC(contractAddress, functionName, parameter, nonPersistentExecution);
650
+ async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
651
+ if (nonPersistentExecution) {
652
+ return this.nonPersistentCallSC(contractAddress, functionName, parameter, amount, fee, maxGas);
629
653
  }
630
654
  // convert parameter to base64
631
655
  let args = '';
@@ -674,15 +698,12 @@ class MassaStationAccount {
674
698
  }
675
699
  return node;
676
700
  }
677
- async nonPersistentCallSC(contractAddress, functionName, parameter, dryRun) {
701
+ async nonPersistentCallSC(contractAddress, functionName, parameter, amount, fee, maxGas) {
678
702
  const node = await this.getNodeUrlFromMassaStation();
679
703
  // Gas amount check
680
- if (!dryRun.maxGas) {
681
- dryRun.maxGas = MAX_READ_BLOCK_GAS;
682
- }
683
- if (dryRun.maxGas > MAX_READ_BLOCK_GAS) {
704
+ if (maxGas > MAX_READ_BLOCK_GAS) {
684
705
  throw new Error(`
685
- The gas submitted ${dryRun.maxGas.toString()} exceeds the max. allowed block gas of
706
+ The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of
686
707
  ${MAX_READ_BLOCK_GAS.toString()}
687
708
  `);
688
709
  }
@@ -696,7 +717,7 @@ class MassaStationAccount {
696
717
  }
697
718
  // setup the request body
698
719
  const data = {
699
- max_gas: Number(dryRun.maxGas),
720
+ max_gas: Number(maxGas),
700
721
  target_address: contractAddress,
701
722
  target_function: functionName,
702
723
  parameter: argumentArray,
@@ -3,7 +3,6 @@ import { IAccountSignResponse } from './AccountSign';
3
3
  import { IAccountDetails } from './IAccountDetails';
4
4
  import { ITransactionDetails } from '..';
5
5
  import { IAccount } from './IAccount';
6
- import { NonPersistentExecution } from './INonPersistentExecution';
7
6
  import { Args, IContractReadOperationResponse } from '@massalabs/massa-web3';
8
7
  /**
9
8
  * This module contains the Account class. It is responsible for representing an account in the wallet.
@@ -74,23 +73,31 @@ export declare class Account implements IAccount {
74
73
  /**
75
74
  * This method aims to transfer MAS on behalf of the sender to a recipient.
76
75
  *
77
- * @param amount - The amount of MAS to be transferred.
78
- * @param fee - The fee to be paid for the transaction execution by the node..
76
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
77
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
79
78
  * @returns An ITransactionDetails object. It contains the operationId on the network.
80
79
  */
81
80
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
82
81
  /**
83
- * This method aims to interact with a smart contract deployed on the massa blockchain on behalf of the sender.
82
+ * This method aims to interact with a smart contract deployed on the MASSA blockchain.
83
+ *
84
+ * @remarks
85
+ * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
86
+ * IContractReadOperationResponse object which contains all the information about the dry run
87
+ * (state changes, gas used, etc.)
84
88
  *
85
89
  * @param contractAddress - The address of the smart contract.
86
90
  * @param functionName - The name of the function to be called.
87
91
  * @param parameter - The parameters as an Args object to be passed to the function.
88
- * @param amount - The amount of MASSA coins to be sent to the block creator.
92
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
93
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
94
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
95
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
96
+ *
97
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
98
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
89
99
  *
90
- * @returns An ITransactionDetails object.
91
- * - It contains the first event emitted by the contract.
92
- * - If the contract does not emit any event, it contains "Function called successfully but no event generated"
93
100
  */
94
- callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, nonPersistentExecution?: NonPersistentExecution): Promise<ITransactionDetails | IContractReadOperationResponse>;
101
+ callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): Promise<ITransactionDetails | IContractReadOperationResponse>;
95
102
  }
96
103
  //# sourceMappingURL=Account.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/account/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAqB,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE7E;;;;;;G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M,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;CA0BjE"}
@@ -117,8 +117,8 @@ class Account {
117
117
  /**
118
118
  * This method aims to transfer MAS on behalf of the sender to a recipient.
119
119
  *
120
- * @param amount - The amount of MAS to be transferred.
121
- * @param fee - The fee to be paid for the transaction execution by the node..
120
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
121
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
122
122
  * @returns An ITransactionDetails object. It contains the operationId on the network.
123
123
  */
124
124
  async sendTransaction(amount, recipientAddress, fee) {
@@ -135,20 +135,26 @@ class Account {
135
135
  });
136
136
  }
137
137
  /**
138
- * This method aims to interact with a smart contract deployed on the massa blockchain on behalf of the sender.
138
+ * This method aims to interact with a smart contract deployed on the MASSA blockchain.
139
+ *
140
+ * @remarks
141
+ * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
142
+ * IContractReadOperationResponse object which contains all the information about the dry run
143
+ * (state changes, gas used, etc.)
139
144
  *
140
145
  * @param contractAddress - The address of the smart contract.
141
146
  * @param functionName - The name of the function to be called.
142
147
  * @param parameter - The parameters as an Args object to be passed to the function.
143
- * @param amount - The amount of MASSA coins to be sent to the block creator.
148
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
149
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
150
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
151
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
152
+ *
153
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
154
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
144
155
  *
145
- * @returns An ITransactionDetails object.
146
- * - It contains the first event emitted by the contract.
147
- * - If the contract does not emit any event, it contains "Function called successfully but no event generated"
148
156
  */
149
- async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
150
- isNPE: false,
151
- }) {
157
+ async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
152
158
  return new Promise((resolve, reject) => {
153
159
  Connector_1.connector.sendMessageToContentScript(this._providerName, __1.AvailableCommands.AccountCallSC, {
154
160
  nickname: this._name,
@@ -156,11 +162,13 @@ class Account {
156
162
  at: contractAddress,
157
163
  args: parameter,
158
164
  coins: amount,
165
+ fee: fee,
166
+ maxGas: maxGas,
159
167
  nonPersistentExecution: nonPersistentExecution,
160
168
  }, (result, err) => {
161
169
  if (err)
162
170
  return reject(err);
163
- return resolve(nonPersistentExecution?.isNPE
171
+ return resolve(nonPersistentExecution
164
172
  ? result
165
173
  : result);
166
174
  });
@@ -2,7 +2,6 @@ import { ITransactionDetails } from '..';
2
2
  import { IAccountBalanceResponse } from './AccountBalance';
3
3
  import { IAccountSignResponse } from './AccountSign';
4
4
  import { Args } from '@massalabs/massa-web3';
5
- import { NonPersistentExecution } from './INonPersistentExecution';
6
5
  /**
7
6
  * This interface represents an Account object.
8
7
  *
@@ -16,6 +15,6 @@ export interface IAccount {
16
15
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
17
16
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
18
17
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
19
- callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, nonPersistentExecution?: NonPersistentExecution): any;
18
+ callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): any;
20
19
  }
21
20
  //# sourceMappingURL=IAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IAccount.d.ts","sourceRoot":"","sources":["../../src/account/IAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EAAE,uBAAu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;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;IACf,YAAY,IAAI,MAAM,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrE,eAAe,CACb,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,MAAM,CACJ,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,CAAC,EAAE,OAAO,OAChC;CACH"}
@@ -1,5 +1,4 @@
1
1
  import { Args } from '@massalabs/massa-web3';
2
- import { NonPersistentExecution } from './INonPersistentExecution';
3
2
  /**
4
3
  * This interface represents the request object to send to the content script to
5
4
  * interact with a deployed smart contract.
@@ -20,6 +19,7 @@ export interface IAccountCallSCRequest {
20
19
  at: string;
21
20
  args: Args;
22
21
  coins: bigint;
23
- nonPersistentExecution: NonPersistentExecution;
22
+ fee: bigint;
23
+ nonPersistentExecution: boolean;
24
24
  }
25
25
  //# sourceMappingURL=IAccountCallSCRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IAccountCallSCRequest.d.ts","sourceRoot":"","sources":["../../src/account/IAccountCallSCRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB,EAAE,sBAAsB,CAAC;CAChD"}
1
+ {"version":3,"file":"IAccountCallSCRequest.d.ts","sourceRoot":"","sources":["../../src/account/IAccountCallSCRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB,EAAE,OAAO,CAAC;CACjC"}
@@ -1,7 +1,6 @@
1
1
  import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse, ITransactionDetails } from '..';
2
2
  import { IAccount } from '../account/IAccount';
3
3
  import { Args, IContractReadOperationResponse } from '@massalabs/massa-web3';
4
- import { NonPersistentExecution } from '../account/INonPersistentExecution';
5
4
  /**
6
5
  * This module contains the MassaStationAccount class. It is responsible for representing an account in
7
6
  * the MassaStation wallet.
@@ -72,8 +71,8 @@ export declare class MassaStationAccount implements IAccount {
72
71
  /**
73
72
  * This method aims to transfer MAS on behalf of the sender to a recipient.
74
73
  *
75
- * @param amount - The amount of MAS to be transferred.
76
- * @param fee - The fee to be paid for the transaction execution by the node.
74
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
75
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
77
76
  * @returns An ITransactionDetails object. It contains the operationId on the network.
78
77
  */
79
78
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
@@ -88,16 +87,17 @@ export declare class MassaStationAccount implements IAccount {
88
87
  * @param contractAddress - The address of the smart contract.
89
88
  * @param functionName - The name of the function to be called.
90
89
  * @param parameter - The parameters as an Args object to be passed to the function.
91
- * @param amount - The amount of MASSA coins to be sent to the block creator.
92
- * @param dryRun - The dryRun object to be passed to the function.
90
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
91
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
92
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
93
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
93
94
  *
94
- * @returns if dryRun.dryRun is true, it returns an IContractReadOperationResponse object. Otherwise,
95
- * it returns an ITransactionDetails object which contains the first event emitted by the contract.
96
- * If the contract does not emit any event, it returns "Function called successfully but no event generated"
95
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
96
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
97
97
  *
98
98
  */
99
- callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, nonPersistentExecution?: NonPersistentExecution): Promise<ITransactionDetails | IContractReadOperationResponse>;
99
+ callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): Promise<ITransactionDetails | IContractReadOperationResponse>;
100
100
  getNodeUrlFromMassaStation(): Promise<string>;
101
- nonPersistentCallSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, dryRun: NonPersistentExecution): Promise<IContractReadOperationResponse>;
101
+ nonPersistentCallSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint): Promise<IContractReadOperationResponse>;
102
102
  }
103
103
  //# sourceMappingURL=MassaStationAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MassaStationAccount.d.ts","sourceRoot":"","sources":["../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EACL,IAAI,EACJ,8BAA8B,EAE/B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAkC5E;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;gBACgB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAM3E;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAqBxD;;;;;OAKG;IACU,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoB3E;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACU,SAAS,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACH,eAAe,CACb,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MA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IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoB3E;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACU,SAAS,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAsB/B;;;;;;;;;;;;;;;;;;;OAmBG;IACU,MAAM,CACjB,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;IAyCnD,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAoB7C,mBAAmB,CAC9B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,8BAA8B,CAAC;CAgE3C"}
@@ -156,12 +156,29 @@ class MassaStationAccount {
156
156
  /**
157
157
  * This method aims to transfer MAS on behalf of the sender to a recipient.
158
158
  *
159
- * @param amount - The amount of MAS to be transferred.
160
- * @param fee - The fee to be paid for the transaction execution by the node.
159
+ * @param amount - The amount of MAS (in the smallest unit) to be transferred.
160
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
161
161
  * @returns An ITransactionDetails object. It contains the operationId on the network.
162
162
  */
163
- sendTransaction(amount, recipientAddress, fee) {
164
- throw new Error('Method not implemented.');
163
+ async sendTransaction(amount, recipientAddress, fee) {
164
+ let sendTxOpResponse = null;
165
+ const url = `${MassaStationProvider_1.MASSA_STATION_ACCOUNTS_URL}/${this._name}/transfer`;
166
+ const body = {
167
+ fee: fee.toString(),
168
+ amount: amount.toString(),
169
+ recipientAddress: recipientAddress,
170
+ };
171
+ try {
172
+ sendTxOpResponse = await (0, RequestHandler_1.postRequest)(url, body);
173
+ }
174
+ catch (ex) {
175
+ console.error(`MassaStation account: error while sending transaction: ${ex}`);
176
+ throw ex;
177
+ }
178
+ if (sendTxOpResponse.isError || sendTxOpResponse.error) {
179
+ throw sendTxOpResponse.error;
180
+ }
181
+ return sendTxOpResponse.result;
165
182
  }
166
183
  /**
167
184
  * This method aims to interact with a smart contract deployed on the MASSA blockchain.
@@ -174,19 +191,18 @@ class MassaStationAccount {
174
191
  * @param contractAddress - The address of the smart contract.
175
192
  * @param functionName - The name of the function to be called.
176
193
  * @param parameter - The parameters as an Args object to be passed to the function.
177
- * @param amount - The amount of MASSA coins to be sent to the block creator.
178
- * @param dryRun - The dryRun object to be passed to the function.
194
+ * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
195
+ * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
196
+ * @param maxGas - The maximum amount of gas to be used for the transaction execution.
197
+ * @param nonPersistentExecution - The dryRun object to be passed to the function.
179
198
  *
180
- * @returns if dryRun.dryRun is true, it returns an IContractReadOperationResponse object. Otherwise,
181
- * it returns an ITransactionDetails object which contains the first event emitted by the contract.
182
- * If the contract does not emit any event, it returns "Function called successfully but no event generated"
199
+ * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
200
+ * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
183
201
  *
184
202
  */
185
- async callSC(contractAddress, functionName, parameter, amount, nonPersistentExecution = {
186
- isNPE: false,
187
- }) {
188
- if (nonPersistentExecution?.isNPE) {
189
- return this.nonPersistentCallSC(contractAddress, functionName, parameter, nonPersistentExecution);
203
+ async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
204
+ if (nonPersistentExecution) {
205
+ return this.nonPersistentCallSC(contractAddress, functionName, parameter, amount, fee, maxGas);
190
206
  }
191
207
  // convert parameter to base64
192
208
  let args = '';
@@ -235,15 +251,12 @@ class MassaStationAccount {
235
251
  }
236
252
  return node;
237
253
  }
238
- async nonPersistentCallSC(contractAddress, functionName, parameter, dryRun) {
254
+ async nonPersistentCallSC(contractAddress, functionName, parameter, amount, fee, maxGas) {
239
255
  const node = await this.getNodeUrlFromMassaStation();
240
256
  // Gas amount check
241
- if (!dryRun.maxGas) {
242
- dryRun.maxGas = MAX_READ_BLOCK_GAS;
243
- }
244
- if (dryRun.maxGas > MAX_READ_BLOCK_GAS) {
257
+ if (maxGas > MAX_READ_BLOCK_GAS) {
245
258
  throw new Error(`
246
- The gas submitted ${dryRun.maxGas.toString()} exceeds the max. allowed block gas of
259
+ The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of
247
260
  ${MAX_READ_BLOCK_GAS.toString()}
248
261
  `);
249
262
  }
@@ -257,7 +270,7 @@ class MassaStationAccount {
257
270
  }
258
271
  // setup the request body
259
272
  const data = {
260
- max_gas: Number(dryRun.maxGas),
273
+ max_gas: Number(maxGas),
261
274
  target_address: contractAddress,
262
275
  target_function: functionName,
263
276
  parameter: argumentArray,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/wallet-provider",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-dev.20230727122300",
4
4
  "description": "massa's wallet provider",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,11 +0,0 @@
1
- /**
2
- * This interface defines specific data that are used to perform a dry run.
3
- *
4
- * @see dryRun - Wether or not to perform a dry run
5
- * @see maxGas - The maximum amount of gas to be used in the dry run
6
- */
7
- export interface NonPersistentExecution {
8
- isNPE: boolean;
9
- maxGas?: bigint;
10
- }
11
- //# sourceMappingURL=INonPersistentExecution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"INonPersistentExecution.d.ts","sourceRoot":"","sources":["../../src/account/INonPersistentExecution.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });