@massalabs/wallet-provider 1.4.2-dev.20230926140020 → 1.4.2-dev.20230929102811

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.
@@ -6,27 +6,22 @@ import { ITransactionDetails } from '..';
6
6
  import { IAccount } from './IAccount';
7
7
  import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
8
8
  /**
9
- * This module contains the Account class. It is responsible for representing an account in the wallet.
10
- *
11
- * @remarks
12
- * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.
13
- *
9
+ * The Account class represents a wallet account. It provides methods for interacting
10
+ * with the account's balance and for signing messages.
14
11
  */
15
12
  export declare class Account implements IAccount {
16
13
  private _providerName;
17
14
  private _address;
18
15
  private _name;
19
16
  /**
20
- * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
17
+ * Initializes a new instance of the Account class.
21
18
  *
22
- * @param address - The address of the account.
23
- * @param name - The name of the account.
24
- * @param providerName - The name of the provider.
25
- * @returns An instance of the Account class.
19
+ * @param address - Account address.
20
+ * @param name - Account name.
21
+ * @param providerName - Blockchain provider name.
26
22
  *
27
23
  * @remarks
28
- * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
29
- * - The IAccountDetails object contains the account's address and name.
24
+ * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.
30
25
  * - The providerName string identifies the provider that is used to interact with the blockchain.
31
26
  */
32
27
  constructor({ address, name }: IAccountDetails, providerName: string);
@@ -43,61 +38,60 @@ export declare class Account implements IAccount {
43
38
  */
44
39
  providerName(): string;
45
40
  /**
46
- * This method aims to retrieve the account's balance.
41
+ * Retrieves the account balance.
47
42
  *
48
- * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
43
+ * @returns A promise that resolves to an object of type IAccountBalanceResponse.
49
44
  */
50
45
  balance(): Promise<IAccountBalanceResponse>;
51
46
  /**
52
- * This method aims to sign a message.
47
+ * Signs a provided message.
53
48
  *
54
- * @param data - The message to be signed.
55
- * @returns An IAccountSignOutput object. It contains the signature of the message.
49
+ * @param data - Message to sign.
50
+ * @returns An IAccountSignOutput object which contains the signature and the public key.
56
51
  */
57
52
  sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
53
  /**
59
- * This method aims to buy rolls on behalf of the sender.
54
+ * Purchases rolls for the sender.
60
55
  *
61
- * @param amount - The amount of rolls to be purchased
62
- * @param fee - The fee to be paid for the transaction execution by the node..
63
- * @returns An ITransactionDetails object. It contains the operationId on the network.
56
+ * @param amount - Number of rolls to purchase.
57
+ * @param fee - Transaction execution fee (in smallest unit).
58
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
64
59
  */
65
60
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
66
61
  /**
67
- * This method aims to sell rolls on behalf of the sender.
62
+ * Sells rolls on behalf of the sender.
68
63
  *
69
- * @param amount - The amount of rolls to be sold.
70
- * @param fee - The fee to be paid for the transaction execution by the node..
71
- * @returns An ITransactionDetails object. It contains the operationId on the network.
64
+ * @param amount - Number of rolls to sell.
65
+ * @param fee - Transaction execution fee (in smallest unit).
66
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
72
67
  */
73
68
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
74
69
  /**
75
- * This method aims to transfer MAS on behalf of the sender to a recipient.
70
+ * Transfers MAS from the sender to a recipient.
76
71
  *
77
- * @param amount - The amount of MAS (in the smallest unit) to be transferred.
78
- * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
79
- * @returns An ITransactionDetails object. It contains the operationId on the network.
72
+ * @param amount - Amount of MAS to transfer (in smallest unit).
73
+ * @param recipientAddress - Recipient's address.
74
+ * @param fee - Transaction execution fee (in smallest unit).
75
+ *
76
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
80
77
  */
81
78
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
82
79
  /**
83
- * This method aims to interact with a smart contract deployed on the MASSA blockchain.
80
+ * Interacts with a smart contract on the MASSA blockchain.
84
81
  *
85
82
  * @remarks
86
- * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
87
- * IContractReadOperationResponse object which contains all the information about the dry run
88
- * (state changes, gas used, etc.)
89
- *
90
- * @param contractAddress - The address of the smart contract.
91
- * @param functionName - The name of the function to be called.
92
- * @param parameter - The parameters as an Args object to be passed to the function.
93
- * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
94
- * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
95
- * @param maxGas - The maximum amount of gas to be used for the transaction execution.
96
- * @param nonPersistentExecution - The dryRun object to be passed to the function.
83
+ * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.
97
84
  *
98
- * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
99
- * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
85
+ * @param contractAddress - Smart contract address.
86
+ * @param functionName - Function name to call.
87
+ * @param parameter - Function parameters.
88
+ * @param amount - Amount of MASSA coins to send (in smallest unit).
89
+ * @param fee - Transaction execution fee (in smallest unit).
90
+ * @param maxGas - Maximum gas for transaction execution.
91
+ * @param nonPersistentExecution - Whether to perform a dry run.
100
92
  *
93
+ * @returns A promise resolving to either:
94
+ * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).
101
95
  */
102
96
  callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): Promise<ITransactionDetails | IContractReadOperationResponse>;
103
97
  }
@@ -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,EAAE,kBAAkB,EAAuB,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,mB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;;;;;OAQG;IACU,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;;;;;;;;;;;;;;;OAgBG;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;CA0BjE"}
@@ -4,24 +4,19 @@ exports.Account = void 0;
4
4
  const Connector_1 = require("../connector/Connector");
5
5
  const __1 = require("..");
6
6
  /**
7
- * This module contains the Account class. It is responsible for representing an account in the wallet.
8
- *
9
- * @remarks
10
- * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.
11
- *
7
+ * The Account class represents a wallet account. It provides methods for interacting
8
+ * with the account's balance and for signing messages.
12
9
  */
13
10
  class Account {
14
11
  /**
15
- * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
12
+ * Initializes a new instance of the Account class.
16
13
  *
17
- * @param address - The address of the account.
18
- * @param name - The name of the account.
19
- * @param providerName - The name of the provider.
20
- * @returns An instance of the Account class.
14
+ * @param address - Account address.
15
+ * @param name - Account name.
16
+ * @param providerName - Blockchain provider name.
21
17
  *
22
18
  * @remarks
23
- * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
24
- * - The IAccountDetails object contains the account's address and name.
19
+ * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.
25
20
  * - The providerName string identifies the provider that is used to interact with the blockchain.
26
21
  */
27
22
  constructor({ address, name }, providerName) {
@@ -48,9 +43,9 @@ class Account {
48
43
  return this._providerName;
49
44
  }
50
45
  /**
51
- * This method aims to retrieve the account's balance.
46
+ * Retrieves the account balance.
52
47
  *
53
- * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
48
+ * @returns A promise that resolves to an object of type IAccountBalanceResponse.
54
49
  */
55
50
  async balance() {
56
51
  return new Promise((resolve, reject) => {
@@ -62,10 +57,10 @@ class Account {
62
57
  });
63
58
  }
64
59
  /**
65
- * This method aims to sign a message.
60
+ * Signs a provided message.
66
61
  *
67
- * @param data - The message to be signed.
68
- * @returns An IAccountSignOutput object. It contains the signature of the message.
62
+ * @param data - Message to sign.
63
+ * @returns An IAccountSignOutput object which contains the signature and the public key.
69
64
  */
70
65
  async sign(data) {
71
66
  return new Promise((resolve, reject) => {
@@ -77,11 +72,11 @@ class Account {
77
72
  });
78
73
  }
79
74
  /**
80
- * This method aims to buy rolls on behalf of the sender.
75
+ * Purchases rolls for the sender.
81
76
  *
82
- * @param amount - The amount of rolls to be purchased
83
- * @param fee - The fee to be paid for the transaction execution by the node..
84
- * @returns An ITransactionDetails object. It contains the operationId on the network.
77
+ * @param amount - Number of rolls to purchase.
78
+ * @param fee - Transaction execution fee (in smallest unit).
79
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
85
80
  */
86
81
  async buyRolls(amount, fee) {
87
82
  return new Promise((resolve, reject) => {
@@ -96,11 +91,11 @@ class Account {
96
91
  });
97
92
  }
98
93
  /**
99
- * This method aims to sell rolls on behalf of the sender.
94
+ * Sells rolls on behalf of the sender.
100
95
  *
101
- * @param amount - The amount of rolls to be sold.
102
- * @param fee - The fee to be paid for the transaction execution by the node..
103
- * @returns An ITransactionDetails object. It contains the operationId on the network.
96
+ * @param amount - Number of rolls to sell.
97
+ * @param fee - Transaction execution fee (in smallest unit).
98
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
104
99
  */
105
100
  async sellRolls(amount, fee) {
106
101
  return new Promise((resolve, reject) => {
@@ -115,11 +110,13 @@ class Account {
115
110
  });
116
111
  }
117
112
  /**
118
- * This method aims to transfer MAS on behalf of the sender to a recipient.
113
+ * Transfers MAS from the sender to a recipient.
119
114
  *
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
- * @returns An ITransactionDetails object. It contains the operationId on the network.
115
+ * @param amount - Amount of MAS to transfer (in smallest unit).
116
+ * @param recipientAddress - Recipient's address.
117
+ * @param fee - Transaction execution fee (in smallest unit).
118
+ *
119
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
123
120
  */
124
121
  async sendTransaction(amount, recipientAddress, fee) {
125
122
  return new Promise((resolve, reject) => {
@@ -135,24 +132,21 @@ class Account {
135
132
  });
136
133
  }
137
134
  /**
138
- * This method aims to interact with a smart contract deployed on the MASSA blockchain.
135
+ * Interacts with a smart contract on the MASSA blockchain.
139
136
  *
140
137
  * @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.)
144
- *
145
- * @param contractAddress - The address of the smart contract.
146
- * @param functionName - The name of the function to be called.
147
- * @param parameter - The parameters as an Args object to be passed to the function.
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.
138
+ * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.
152
139
  *
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.
140
+ * @param contractAddress - Smart contract address.
141
+ * @param functionName - Function name to call.
142
+ * @param parameter - Function parameters.
143
+ * @param amount - Amount of MASSA coins to send (in smallest unit).
144
+ * @param fee - Transaction execution fee (in smallest unit).
145
+ * @param maxGas - Maximum gas for transaction execution.
146
+ * @param nonPersistentExecution - Whether to perform a dry run.
155
147
  *
148
+ * @returns A promise resolving to either:
149
+ * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).
156
150
  */
157
151
  async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
158
152
  return new Promise((resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Account.js","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":";;;AAKA,sDAAmD;AAEnD,0BAA4D;AAO5D;;;;;;GAMG;AACH,MAAa,OAAO;IAKlB;;;;;;;;;;;;OAYG;IACH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,OAAO,CAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9D,qBAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,qBAAiB,CAAC,cAAc,EAChC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAA4B,EACpD,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,MAAiC,CAAC,CAAC;YACpD,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,IAAyB;QACzC,OAAO,IAAI,OAAO,CAAqB,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BACd,sBAAsB,EAAE,sBAAsB;aACtB,EAC1B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CACZ,sBAAsB;oBACpB,CAAC,CAAE,MAAyC;oBAC5C,CAAC,CAAE,MAA8B,CACpC,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA7ND,0BA6NC","sourcesContent":["import {\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n} from './AccountBalance';\nimport { IAccountSignOutput, IAccountSignRequest } from './AccountSign';\nimport { connector } from '../connector/Connector';\nimport { IAccountDetails } from './IAccountDetails';\nimport { AvailableCommands, ITransactionDetails } from '..';\nimport { IAccount } from './IAccount';\nimport { IAccountRollsRequest } from './IAccountRolls';\nimport { IAccountSendTransactionRequest } from './IAccountSendTransaction';\nimport { IAccountCallSCRequest } from './IAccountCallSCRequest';\nimport { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';\n\n/**\n * This module contains the Account class. It is responsible for representing an account in the wallet.\n *\n * @remarks\n * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.\n *\n */\nexport class Account implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n\n /**\n * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.\n *\n * @param address - The address of the account.\n * @param name - The name of the account.\n * @param providerName - The name of the provider.\n * @returns An instance of the Account class.\n *\n * @remarks\n * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.\n * - The IAccountDetails object contains the account's address and name.\n * - The providerName string identifies the provider that is used to interact with the blockchain.\n */\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? '';\n this._providerName = providerName;\n }\n\n /**\n * @returns The address of the account.\n */\n public address(): string {\n return this._address;\n }\n\n /**\n * @returns The name of the account.\n */\n public name(): string {\n return this._name;\n }\n\n /**\n * @returns The name of the provider.\n */\n public providerName(): string {\n return this._providerName;\n }\n\n /**\n * This method aims to retrieve the account's balance.\n *\n * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.\n */\n public async balance(): Promise<IAccountBalanceResponse> {\n return new Promise<IAccountBalanceResponse>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBalance,\n { address: this._address } as IAccountBalanceRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountBalanceResponse);\n },\n );\n });\n }\n\n /**\n * This method aims to sign a message.\n *\n * @param data - The message to be signed.\n * @returns An IAccountSignOutput object. It contains the signature of the message.\n */\n public async sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput> {\n return new Promise<IAccountSignOutput>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSign,\n { address: this._address, data } as IAccountSignRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountSignOutput);\n },\n );\n });\n }\n\n /**\n * This method aims to buy rolls on behalf of the sender.\n *\n * @param amount - The amount of rolls to be purchased\n * @param fee - The fee to be paid for the transaction execution by the node..\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBuyRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n } as IAccountRollsRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to sell rolls on behalf of the sender.\n *\n * @param amount - The amount of rolls to be sold.\n * @param fee - The fee to be paid for the transaction execution by the node..\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSellRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n } as IAccountRollsRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to transfer MAS on behalf of the sender to a recipient.\n *\n * @param amount - The amount of MAS (in the smallest unit) to be transferred.\n * @param fee - The fee to be paid for the transaction execution (in the smallest unit).\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSendTransaction,\n {\n amount: amount.toString(),\n recipientAddress,\n fee: fee.toString(),\n } as IAccountSendTransactionRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to interact with a smart contract deployed on the MASSA blockchain.\n *\n * @remarks\n * If dryRun.dryRun is true, the method will dry run the smart contract call and return an\n * IContractReadOperationResponse object which contains all the information about the dry run\n * (state changes, gas used, etc.)\n *\n * @param contractAddress - The address of the smart contract.\n * @param functionName - The name of the function to be called.\n * @param parameter - The parameters as an Args object to be passed to the function.\n * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).\n * @param fee - The fee to be paid for the transaction execution (in the smallest unit).\n * @param maxGas - The maximum amount of gas to be used for the transaction execution.\n * @param nonPersistentExecution - The dryRun object to be passed to the function.\n *\n * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.\n * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.\n *\n */\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n return new Promise((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountCallSC,\n {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: parameter,\n coins: amount,\n fee: fee,\n maxGas: maxGas,\n nonPersistentExecution: nonPersistentExecution,\n } as IAccountCallSCRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(\n nonPersistentExecution\n ? (result as IContractReadOperationResponse)\n : (result as ITransactionDetails),\n );\n },\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Account.js","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":";;;AAEA,sDAAmD;AAEnD,0BAA4D;AAI5D;;;GAGG;AACH,MAAa,OAAO;IAKlB;;;;;;;;;;OAUG;IAEH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,OAAO,CAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9D,qBAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,qBAAiB,CAAC,cAAc,EAChC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,EAC1B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,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C,KAAK;gBACpB,IAAI,EAAE,YAAY;gBAClB,EAAE,EAAE,eAAe;gBACnB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM;gBACd,sBAAsB,EAAE,sBAAsB;aAC/C,EACD,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CACZ,sBAAsB;oBACpB,CAAC,CAAE,MAAyC;oBAC5C,CAAC,CAAE,MAA8B,CACpC,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA3ND,0BA2NC","sourcesContent":["import { IAccountBalanceResponse } from './AccountBalance';\nimport { IAccountSignOutput } from './AccountSign';\nimport { connector } from '../connector/Connector';\nimport { IAccountDetails } from './IAccountDetails';\nimport { AvailableCommands, ITransactionDetails } from '..';\nimport { IAccount } from './IAccount';\nimport { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';\n\n/**\n * The Account class represents a wallet account. It provides methods for interacting\n * with the account's balance and for signing messages.\n */\nexport class Account implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n\n /**\n * Initializes a new instance of the Account class.\n *\n * @param address - Account address.\n * @param name - Account name.\n * @param providerName - Blockchain provider name.\n *\n * @remarks\n * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.\n * - The providerName string identifies the provider that is used to interact with the blockchain.\n */\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? '';\n this._providerName = providerName;\n }\n\n /**\n * @returns The address of the account.\n */\n public address(): string {\n return this._address;\n }\n\n /**\n * @returns The name of the account.\n */\n public name(): string {\n return this._name;\n }\n\n /**\n * @returns The name of the provider.\n */\n public providerName(): string {\n return this._providerName;\n }\n\n /**\n * Retrieves the account balance.\n *\n * @returns A promise that resolves to an object of type IAccountBalanceResponse.\n */\n public async balance(): Promise<IAccountBalanceResponse> {\n return new Promise<IAccountBalanceResponse>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBalance,\n { address: this._address },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountBalanceResponse);\n },\n );\n });\n }\n\n /**\n * Signs a provided message.\n *\n * @param data - Message to sign.\n * @returns An IAccountSignOutput object which contains the signature and the public key.\n */\n public async sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput> {\n return new Promise<IAccountSignOutput>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSign,\n { address: this._address, data },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountSignOutput);\n },\n );\n });\n }\n\n /**\n * Purchases rolls for the sender.\n *\n * @param amount - Number of rolls to purchase.\n * @param fee - Transaction execution fee (in smallest unit).\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBuyRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Sells rolls on behalf of the sender.\n *\n * @param amount - Number of rolls to sell.\n * @param fee - Transaction execution fee (in smallest unit).\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSellRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Transfers MAS from the sender to a recipient.\n *\n * @param amount - Amount of MAS to transfer (in smallest unit).\n * @param recipientAddress - Recipient's address.\n * @param fee - Transaction execution fee (in smallest unit).\n *\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSendTransaction,\n {\n amount: amount.toString(),\n recipientAddress,\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Interacts with a smart contract on the MASSA blockchain.\n *\n * @remarks\n * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.\n *\n * @param contractAddress - Smart contract address.\n * @param functionName - Function name to call.\n * @param parameter - Function parameters.\n * @param amount - Amount of MASSA coins to send (in smallest unit).\n * @param fee - Transaction execution fee (in smallest unit).\n * @param maxGas - Maximum gas for transaction execution.\n * @param nonPersistentExecution - Whether to perform a dry run.\n *\n * @returns A promise resolving to either:\n * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).\n */\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n return new Promise((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountCallSC,\n {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: parameter,\n coins: amount,\n fee: fee,\n maxGas: maxGas,\n nonPersistentExecution: nonPersistentExecution,\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(\n nonPersistentExecution\n ? (result as IContractReadOperationResponse)\n : (result as ITransactionDetails),\n );\n },\n );\n });\n }\n}\n"]}
@@ -1,11 +1,16 @@
1
1
  /**
2
- * This interface represents the request object of the AccountBalance command.
2
+ * Represents the request for an AccountBalance command.
3
+ *
4
+ * address - The account address.
3
5
  */
4
6
  export interface IAccountBalanceRequest {
5
7
  address: string;
6
8
  }
7
9
  /**
8
- * This interface represents the response object of the AccountBalance command sent by the content script.
10
+ * Represents the response from an AccountBalance command.
11
+ *
12
+ * finalBalance - The account's final confirmed balance.
13
+ * candidateBalance - The account's pending balance.
9
14
  */
10
15
  export interface IAccountBalanceResponse {
11
16
  finalBalance: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
1
+ {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object of the AccountBalance command.\n */\nexport interface IAccountBalanceRequest {\n address: string;\n}\n\n/**\n * This interface represents the response object of the AccountBalance command sent by the content script.\n */\nexport interface IAccountBalanceResponse {\n finalBalance: string;\n candidateBalance: string;\n}\n"]}
1
+ {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents the request for an AccountBalance command.\n *\n * address - The account address.\n */\nexport interface IAccountBalanceRequest {\n address: string;\n}\n\n/**\n * Represents the response from an AccountBalance command.\n *\n * finalBalance - The account's final confirmed balance.\n * candidateBalance - The account's pending balance.\n */\nexport interface IAccountBalanceResponse {\n finalBalance: string;\n candidateBalance: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BearbyAccount.d.ts","sourceRoot":"","sources":["../../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAO5D;;GAEG;AACH,eAAO,MAAM,eAAe,sCAAsC,CAAC;AAEnE,oBAAY,cAAc;IACxB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,SAAS,IAAA;IACT,MAAM,IAAA;CACP;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,WAAW,IAAI;IACf,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,MAAM,IAAI;CACX;AAQD,qBAAa,aAAc,YAAW,QAAQ;IAC5C,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAmB;gBAEhB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAMpE,OAAO,IAAI,MAAM;IAIjB,IA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BACE,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,wBAAwB;gBAChC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;gBAChB,EAAE,EAAE,CAAC;aACN;SACF,CAAC;QACF,wBAAwB;QACxB,IAAI,iBAAiB,GAAsC,EAAE,CAAC;QAC9D,IAAI;YACF,IAAI,IAAI,GAAG,MAAM,IAAA,4BAAW,EAC1B,IAAI,EACJ,IAAI,CACL,CAAC;YACF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;SACjC;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,IAAI,KAAK,CACb,sEAAsE,EAAE,EAAE,CAC3E,CAAC;SACH;QACD,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CACb,4FAA4F,CAC7F,CAAC;SACH;QACD,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO;YACL,WAAW,EAAE,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF;AApUD,sCAoUC","sourcesContent":["import {\n ArgTypes,\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\nimport { ITransactionDetails } from '..';\nimport {\n IAccountBalanceResponse,\n IAccountDetails,\n IAccountSignResponse,\n} from '../account';\nimport { IAccount } from '../account/IAccount';\nimport { web3 } from '@hicaru/bearby.js';\nimport {\n postRequest,\n JsonRpcResponseData,\n} from '../massaStation/RequestHandler';\nimport { BalanceResponse } from './BalanceResponse';\nimport { NodeStatus } from './NodeStatus';\nimport { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';\nimport axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';\nimport { decode } from 'bs58check';\nimport { IAccountSignOutput } from '../account/AccountSign';\nimport { isArrayOfNumbers } from '../utils/typeCheck';\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * The RPC we are using to query the node\n */\nexport const PUBLIC_NODE_RPC = 'https://buildnet.massa.net/api/v2';\n\nexport enum OperationsType {\n Payment,\n RollBuy,\n RollSell,\n ExecuteSC,\n CallSC,\n}\n\n/**\n * Associates an operation type with a number.\n */\nexport enum OperationTypeId {\n Transaction = 0,\n RollBuy = 1,\n RollSell = 2,\n ExecuteSC = 3,\n CallSC = 4,\n}\n\nconst requestHeaders = {\n Accept:\n 'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Content-Type': 'application/json',\n} as AxiosRequestHeaders;\n\nexport class BearbyAccount implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n private _nodeUrl = PUBLIC_NODE_RPC;\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? 'Bearby_account';\n this._providerName = providerName;\n }\n\n public address(): string {\n return this._address;\n }\n\n public name(): string {\n return this._name;\n }\n\n public providerName(): string {\n return this._providerName;\n }\n\n public async connect() {\n try {\n await web3.wallet.connect();\n } catch (ex) {\n console.log('Bearby connection error: ', ex);\n }\n }\n\n // needs testing\n public async balance(): Promise<IAccountBalanceResponse> {\n await this.connect();\n // Not available on bearby. we have to manually call the api\n const body = {\n jsonrpc: '2.0',\n method: 'get_addresses',\n params: [[this._address]],\n id: 0,\n };\n\n const addressInfos = await postRequest<BalanceResponse>(\n PUBLIC_NODE_RPC,\n body,\n );\n\n if (addressInfos.isError || addressInfos.error) {\n throw addressInfos.error.message;\n }\n return {\n finalBalance: addressInfos.result.result[0].final_balance,\n candidateBalance: addressInfos.result.result[0].candidate_balance,\n } as IAccountBalanceResponse;\n }\n\n // need testing\n public async sign(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignOutput> {\n await this.connect();\n\n let strData: string;\n if (data instanceof Uint8Array) {\n strData = new TextDecoder().decode(data);\n }\n if (data instanceof Buffer) {\n strData = data.toString();\n }\n const signature = await web3.wallet.signMessage(strData);\n return {\n publicKey: signature.publicKey,\n base58Encoded: signature.signature,\n };\n }\n\n // need testing\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.buyRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n // need testing\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.sellRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n\n const operationId = await web3.massa.payment(\n amount.toString(),\n recipientAddress,\n );\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Args | Uint8Array,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n await this.connect();\n if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n\n const operationId = await web3.contract.call({\n maxGas: Number(maxGas),\n coins: Number(amount),\n fee: Number(fee),\n targetAddress: contractAddress,\n functionName: functionName,\n unsafeParameters: isArrayOfNumbers(parameter)\n ? (parameter as Uint8Array)\n : ((parameter as Args).serialize() as unknown as Uint8Array),\n });\n\n return { operationId };\n }\n\n /**\n * Retrieves the node's status.\n *\n * @remarks\n * The returned information includes:\n * - Whether the node is reachable\n * - The number of connected peers\n * - The node's version\n * - The node's configuration parameters\n *\n * @returns A promise that resolves to the node's status information.\n */\n public async getNodeStatus(): Promise<NodeStatus> {\n const jsonRpcRequestMethod = JSON_RPC_REQUEST_METHOD.GET_STATUS;\n return await this.sendJsonRPCRequest<NodeStatus>(jsonRpcRequestMethod, []);\n }\n\n /**\n * Sends a post JSON rpc request to the node.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @throws An error if the rpc method returns an error.\n *\n * @returns A promise that resolves as the result of the rpc method.\n */\n protected async sendJsonRPCRequest<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<T> {\n let resp: JsonRpcResponseData<T> = null;\n resp = await this.promisifyJsonRpcCall(resource, params);\n\n // in case of rpc error, rethrow the error.\n if (resp.isError || resp.error) {\n throw resp.error;\n }\n\n return resp.result;\n }\n\n /**\n * Converts a json rpc call to a promise that resolves as a JsonRpcResponseData\n *\n * @privateRemarks\n * If there is an error while sending the request, the function catches the error, the isError\n * property is set to true, the result property set to null, and the error property set to a\n * new Error object with a message indicating that there was an error.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @returns A promise that resolves as a JsonRpcResponseData.\n */\n private async promisifyJsonRpcCall<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<JsonRpcResponseData<T>> {\n let resp: AxiosResponse<JsonRpcResponseData<T>> = null;\n\n const body = {\n jsonrpc: '2.0',\n method: resource,\n params: params,\n id: 0,\n };\n\n try {\n resp = await axios.post(this._nodeUrl, body, { headers: requestHeaders });\n } catch (ex) {\n return {\n isError: true,\n result: null,\n error: new Error('JSON.parse error: ' + String(ex)),\n } as JsonRpcResponseData<T>;\n }\n\n const responseData: JsonRpcResponseData<T> = resp.data;\n\n if (responseData.error) {\n return {\n isError: true,\n result: null,\n error: new Error(responseData.error.message),\n } as JsonRpcResponseData<T>;\n }\n\n return {\n isError: false,\n result: responseData.result as T,\n error: null,\n } as JsonRpcResponseData<T>;\n }\n\n public async nonPersistentCallSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n ): Promise<IContractReadOperationResponse> {\n // not clean but bearby doesn't allow us to get its node urls\n const node = PUBLIC_NODE_RPC;\n // Gas amount check\n if (maxGas > MAX_READ_BLOCK_GAS) {\n throw new Error(\n `\n The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of \n ${MAX_READ_BLOCK_GAS.toString()}\n `,\n );\n }\n\n // convert parameter to an array of numbers\n let argumentArray = [];\n if (parameter instanceof Uint8Array) {\n argumentArray = Array.from(parameter);\n } else {\n argumentArray = Array.from(parameter.serialize());\n }\n // setup the request body\n const data = {\n max_gas: Number(maxGas),\n target_address: contractAddress,\n target_function: functionName,\n parameter: argumentArray,\n caller_address: this._address,\n coins: Number(amount),\n fee: Number(fee),\n };\n const body = [\n {\n jsonrpc: '2.0',\n method: 'execute_read_only_call',\n params: [[data]],\n id: 0,\n },\n ];\n // returns operation ids\n let jsonRpcCallResult: Array<IContractReadOperationData> = [];\n try {\n let resp = await postRequest<Array<IContractReadOperationData>>(\n node,\n body,\n );\n if (resp.isError || resp.error) {\n throw resp.error.message;\n }\n jsonRpcCallResult = resp.result;\n } catch (ex) {\n throw new Error(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n }\n if (jsonRpcCallResult.length <= 0) {\n throw new Error(\n `Read operation bad response. No results array in json rpc response. Inspect smart contract`,\n );\n }\n if (jsonRpcCallResult[0].result.Error) {\n throw new Error(jsonRpcCallResult[0].result.Error);\n }\n return {\n returnValue: new Uint8Array(jsonRpcCallResult[0].result[0].result.Ok),\n info: jsonRpcCallResult[0],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"BearbyAccount.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iB,CAAC,CAAC,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF;AApUD,sCAoUC","sourcesContent":["import {\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\nimport { ITransactionDetails } from '..';\nimport { IAccountBalanceResponse, IAccountDetails } from '../account';\nimport { IAccount } from '../account/IAccount';\nimport { web3 } from '@hicaru/bearby.js';\nimport {\n postRequest,\n JsonRpcResponseData,\n} from '../massaStation/RequestHandler';\nimport { BalanceResponse } from './BalanceResponse';\nimport { NodeStatus } from './NodeStatus';\nimport { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';\nimport axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';\nimport { IAccountSignOutput } from '../account/AccountSign';\nimport { isArrayOfNumbers } from '../utils/typeCheck';\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * The RPC we are using to query the node\n */\nexport const PUBLIC_NODE_RPC = 'https://buildnet.massa.net/api/v2';\n\nexport enum OperationsType {\n Payment,\n RollBuy,\n RollSell,\n ExecuteSC,\n CallSC,\n}\n\n/**\n * Associates an operation type with a number.\n */\nexport enum OperationTypeId {\n Transaction = 0,\n RollBuy = 1,\n RollSell = 2,\n ExecuteSC = 3,\n CallSC = 4,\n}\n\nconst requestHeaders = {\n Accept:\n 'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Content-Type': 'application/json',\n} as AxiosRequestHeaders;\n\nexport class BearbyAccount implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n private _nodeUrl = PUBLIC_NODE_RPC;\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? 'Bearby_account';\n this._providerName = providerName;\n }\n\n public address(): string {\n return this._address;\n }\n\n public name(): string {\n return this._name;\n }\n\n public providerName(): string {\n return this._providerName;\n }\n\n public async connect() {\n try {\n await web3.wallet.connect();\n } catch (ex) {\n console.log('Bearby connection error: ', ex);\n }\n }\n\n // needs testing\n public async balance(): Promise<IAccountBalanceResponse> {\n await this.connect();\n // Not available on bearby. we have to manually call the api\n const body = {\n jsonrpc: '2.0',\n method: 'get_addresses',\n params: [[this._address]],\n id: 0,\n };\n\n const addressInfos = await postRequest<BalanceResponse>(\n PUBLIC_NODE_RPC,\n body,\n );\n\n if (addressInfos.isError || addressInfos.error) {\n throw addressInfos.error.message;\n }\n return {\n finalBalance: addressInfos.result.result[0].final_balance,\n candidateBalance: addressInfos.result.result[0].candidate_balance,\n } as IAccountBalanceResponse;\n }\n\n // need testing\n public async sign(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignOutput> {\n await this.connect();\n\n let strData: string;\n if (data instanceof Uint8Array) {\n strData = new TextDecoder().decode(data);\n }\n if (data instanceof Buffer) {\n strData = data.toString();\n }\n const signature = await web3.wallet.signMessage(strData);\n return {\n publicKey: signature.publicKey,\n base58Encoded: signature.signature,\n };\n }\n\n // need testing\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.buyRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n // need testing\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.sellRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n\n const operationId = await web3.massa.payment(\n amount.toString(),\n recipientAddress,\n );\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Args | Uint8Array,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n await this.connect();\n if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n\n const operationId = await web3.contract.call({\n maxGas: Number(maxGas),\n coins: Number(amount),\n fee: Number(fee),\n targetAddress: contractAddress,\n functionName: functionName,\n unsafeParameters: isArrayOfNumbers(parameter)\n ? (parameter as Uint8Array)\n : ((parameter as Args).serialize() as unknown as Uint8Array),\n });\n\n return { operationId };\n }\n\n /**\n * Retrieves the node's status.\n *\n * @remarks\n * The returned information includes:\n * - Whether the node is reachable\n * - The number of connected peers\n * - The node's version\n * - The node's configuration parameters\n *\n * @returns A promise that resolves to the node's status information.\n */\n public async getNodeStatus(): Promise<NodeStatus> {\n const jsonRpcRequestMethod = JSON_RPC_REQUEST_METHOD.GET_STATUS;\n return await this.sendJsonRPCRequest<NodeStatus>(jsonRpcRequestMethod, []);\n }\n\n /**\n * Sends a post JSON rpc request to the node.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @throws An error if the rpc method returns an error.\n *\n * @returns A promise that resolves as the result of the rpc method.\n */\n protected async sendJsonRPCRequest<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<T> {\n let resp: JsonRpcResponseData<T> = null;\n resp = await this.promisifyJsonRpcCall(resource, params);\n\n // in case of rpc error, rethrow the error.\n if (resp.isError || resp.error) {\n throw resp.error;\n }\n\n return resp.result;\n }\n\n /**\n * Converts a json rpc call to a promise that resolves as a JsonRpcResponseData\n *\n * @privateRemarks\n * If there is an error while sending the request, the function catches the error, the isError\n * property is set to true, the result property set to null, and the error property set to a\n * new Error object with a message indicating that there was an error.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @returns A promise that resolves as a JsonRpcResponseData.\n */\n private async promisifyJsonRpcCall<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<JsonRpcResponseData<T>> {\n let resp: AxiosResponse<JsonRpcResponseData<T>> = null;\n\n const body = {\n jsonrpc: '2.0',\n method: resource,\n params: params,\n id: 0,\n };\n\n try {\n resp = await axios.post(this._nodeUrl, body, { headers: requestHeaders });\n } catch (ex) {\n return {\n isError: true,\n result: null,\n error: new Error('JSON.parse error: ' + String(ex)),\n } as JsonRpcResponseData<T>;\n }\n\n const responseData: JsonRpcResponseData<T> = resp.data;\n\n if (responseData.error) {\n return {\n isError: true,\n result: null,\n error: new Error(responseData.error.message),\n } as JsonRpcResponseData<T>;\n }\n\n return {\n isError: false,\n result: responseData.result as T,\n error: null,\n } as JsonRpcResponseData<T>;\n }\n\n public async nonPersistentCallSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n ): Promise<IContractReadOperationResponse> {\n // not clean but bearby doesn't allow us to get its node urls\n const node = PUBLIC_NODE_RPC;\n // Gas amount check\n if (maxGas > MAX_READ_BLOCK_GAS) {\n throw new Error(\n `\n The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of \n ${MAX_READ_BLOCK_GAS.toString()}\n `,\n );\n }\n\n // convert parameter to an array of numbers\n let argumentArray = [];\n if (parameter instanceof Uint8Array) {\n argumentArray = Array.from(parameter);\n } else {\n argumentArray = Array.from(parameter.serialize());\n }\n // setup the request body\n const data = {\n max_gas: Number(maxGas),\n target_address: contractAddress,\n target_function: functionName,\n parameter: argumentArray,\n caller_address: this._address,\n coins: Number(amount),\n fee: Number(fee),\n };\n const body = [\n {\n jsonrpc: '2.0',\n method: 'execute_read_only_call',\n params: [[data]],\n id: 0,\n },\n ];\n // returns operation ids\n let jsonRpcCallResult: Array<IContractReadOperationData> = [];\n try {\n let resp = await postRequest<Array<IContractReadOperationData>>(\n node,\n body,\n );\n if (resp.isError || resp.error) {\n throw resp.error.message;\n }\n jsonRpcCallResult = resp.result;\n } catch (ex) {\n throw new Error(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n }\n if (jsonRpcCallResult.length <= 0) {\n throw new Error(\n `Read operation bad response. No results array in json rpc response. Inspect smart contract`,\n );\n }\n if (jsonRpcCallResult[0].result.Error) {\n throw new Error(jsonRpcCallResult[0].result.Error);\n }\n return {\n returnValue: new Uint8Array(jsonRpcCallResult[0].result[0].result.Ok),\n info: jsonRpcCallResult[0],\n };\n }\n}\n"]}
@@ -6,27 +6,22 @@ import { ITransactionDetails } from '..';
6
6
  import { IAccount } from './IAccount';
7
7
  import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
8
8
  /**
9
- * This module contains the Account class. It is responsible for representing an account in the wallet.
10
- *
11
- * @remarks
12
- * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.
13
- *
9
+ * The Account class represents a wallet account. It provides methods for interacting
10
+ * with the account's balance and for signing messages.
14
11
  */
15
12
  export declare class Account implements IAccount {
16
13
  private _providerName;
17
14
  private _address;
18
15
  private _name;
19
16
  /**
20
- * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
17
+ * Initializes a new instance of the Account class.
21
18
  *
22
- * @param address - The address of the account.
23
- * @param name - The name of the account.
24
- * @param providerName - The name of the provider.
25
- * @returns An instance of the Account class.
19
+ * @param address - Account address.
20
+ * @param name - Account name.
21
+ * @param providerName - Blockchain provider name.
26
22
  *
27
23
  * @remarks
28
- * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
29
- * - The IAccountDetails object contains the account's address and name.
24
+ * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.
30
25
  * - The providerName string identifies the provider that is used to interact with the blockchain.
31
26
  */
32
27
  constructor({ address, name }: IAccountDetails, providerName: string);
@@ -43,61 +38,60 @@ export declare class Account implements IAccount {
43
38
  */
44
39
  providerName(): string;
45
40
  /**
46
- * This method aims to retrieve the account's balance.
41
+ * Retrieves the account balance.
47
42
  *
48
- * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
43
+ * @returns A promise that resolves to an object of type IAccountBalanceResponse.
49
44
  */
50
45
  balance(): Promise<IAccountBalanceResponse>;
51
46
  /**
52
- * This method aims to sign a message.
47
+ * Signs a provided message.
53
48
  *
54
- * @param data - The message to be signed.
55
- * @returns An IAccountSignOutput object. It contains the signature of the message.
49
+ * @param data - Message to sign.
50
+ * @returns An IAccountSignOutput object which contains the signature and the public key.
56
51
  */
57
52
  sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
53
  /**
59
- * This method aims to buy rolls on behalf of the sender.
54
+ * Purchases rolls for the sender.
60
55
  *
61
- * @param amount - The amount of rolls to be purchased
62
- * @param fee - The fee to be paid for the transaction execution by the node..
63
- * @returns An ITransactionDetails object. It contains the operationId on the network.
56
+ * @param amount - Number of rolls to purchase.
57
+ * @param fee - Transaction execution fee (in smallest unit).
58
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
64
59
  */
65
60
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
66
61
  /**
67
- * This method aims to sell rolls on behalf of the sender.
62
+ * Sells rolls on behalf of the sender.
68
63
  *
69
- * @param amount - The amount of rolls to be sold.
70
- * @param fee - The fee to be paid for the transaction execution by the node..
71
- * @returns An ITransactionDetails object. It contains the operationId on the network.
64
+ * @param amount - Number of rolls to sell.
65
+ * @param fee - Transaction execution fee (in smallest unit).
66
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
72
67
  */
73
68
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
74
69
  /**
75
- * This method aims to transfer MAS on behalf of the sender to a recipient.
70
+ * Transfers MAS from the sender to a recipient.
76
71
  *
77
- * @param amount - The amount of MAS (in the smallest unit) to be transferred.
78
- * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
79
- * @returns An ITransactionDetails object. It contains the operationId on the network.
72
+ * @param amount - Amount of MAS to transfer (in smallest unit).
73
+ * @param recipientAddress - Recipient's address.
74
+ * @param fee - Transaction execution fee (in smallest unit).
75
+ *
76
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
80
77
  */
81
78
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
82
79
  /**
83
- * This method aims to interact with a smart contract deployed on the MASSA blockchain.
80
+ * Interacts with a smart contract on the MASSA blockchain.
84
81
  *
85
82
  * @remarks
86
- * If dryRun.dryRun is true, the method will dry run the smart contract call and return an
87
- * IContractReadOperationResponse object which contains all the information about the dry run
88
- * (state changes, gas used, etc.)
89
- *
90
- * @param contractAddress - The address of the smart contract.
91
- * @param functionName - The name of the function to be called.
92
- * @param parameter - The parameters as an Args object to be passed to the function.
93
- * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).
94
- * @param fee - The fee to be paid for the transaction execution (in the smallest unit).
95
- * @param maxGas - The maximum amount of gas to be used for the transaction execution.
96
- * @param nonPersistentExecution - The dryRun object to be passed to the function.
83
+ * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.
97
84
  *
98
- * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.
99
- * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.
85
+ * @param contractAddress - Smart contract address.
86
+ * @param functionName - Function name to call.
87
+ * @param parameter - Function parameters.
88
+ * @param amount - Amount of MASSA coins to send (in smallest unit).
89
+ * @param fee - Transaction execution fee (in smallest unit).
90
+ * @param maxGas - Maximum gas for transaction execution.
91
+ * @param nonPersistentExecution - Whether to perform a dry run.
100
92
  *
93
+ * @returns A promise resolving to either:
94
+ * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).
101
95
  */
102
96
  callSC(contractAddress: string, functionName: string, parameter: Uint8Array | Args, amount: bigint, fee: bigint, maxGas: bigint, nonPersistentExecution?: boolean): Promise<ITransactionDetails | IContractReadOperationResponse>;
103
97
  }
@@ -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,EAAE,kBAAkB,EAAuB,MAAM,e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,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAiB/B;;;;;;;;OAQG;IACU,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;;;;;;;;;;;;;;;OAgBG;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;CA0BjE"}
@@ -1,27 +1,22 @@
1
1
  import { connector } from '../connector/Connector';
2
2
  import { AvailableCommands } from '..';
3
3
  /**
4
- * This module contains the Account class. It is responsible for representing an account in the wallet.
5
- *
6
- * @remarks
7
- * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.
8
- *
4
+ * The Account class represents a wallet account. It provides methods for interacting
5
+ * with the account's balance and for signing messages.
9
6
  */
10
7
  export class Account {
11
8
  _providerName;
12
9
  _address;
13
10
  _name;
14
11
  /**
15
- * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.
12
+ * Initializes a new instance of the Account class.
16
13
  *
17
- * @param address - The address of the account.
18
- * @param name - The name of the account.
19
- * @param providerName - The name of the provider.
20
- * @returns An instance of the Account class.
14
+ * @param address - Account address.
15
+ * @param name - Account name.
16
+ * @param providerName - Blockchain provider name.
21
17
  *
22
18
  * @remarks
23
- * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.
24
- * - The IAccountDetails object contains the account's address and name.
19
+ * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.
25
20
  * - The providerName string identifies the provider that is used to interact with the blockchain.
26
21
  */
27
22
  constructor({ address, name }, providerName) {
@@ -48,9 +43,9 @@ export class Account {
48
43
  return this._providerName;
49
44
  }
50
45
  /**
51
- * This method aims to retrieve the account's balance.
46
+ * Retrieves the account balance.
52
47
  *
53
- * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.
48
+ * @returns A promise that resolves to an object of type IAccountBalanceResponse.
54
49
  */
55
50
  async balance() {
56
51
  return new Promise((resolve, reject) => {
@@ -62,10 +57,10 @@ export class Account {
62
57
  });
63
58
  }
64
59
  /**
65
- * This method aims to sign a message.
60
+ * Signs a provided message.
66
61
  *
67
- * @param data - The message to be signed.
68
- * @returns An IAccountSignOutput object. It contains the signature of the message.
62
+ * @param data - Message to sign.
63
+ * @returns An IAccountSignOutput object which contains the signature and the public key.
69
64
  */
70
65
  async sign(data) {
71
66
  return new Promise((resolve, reject) => {
@@ -77,11 +72,11 @@ export class Account {
77
72
  });
78
73
  }
79
74
  /**
80
- * This method aims to buy rolls on behalf of the sender.
75
+ * Purchases rolls for the sender.
81
76
  *
82
- * @param amount - The amount of rolls to be purchased
83
- * @param fee - The fee to be paid for the transaction execution by the node..
84
- * @returns An ITransactionDetails object. It contains the operationId on the network.
77
+ * @param amount - Number of rolls to purchase.
78
+ * @param fee - Transaction execution fee (in smallest unit).
79
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
85
80
  */
86
81
  async buyRolls(amount, fee) {
87
82
  return new Promise((resolve, reject) => {
@@ -96,11 +91,11 @@ export class Account {
96
91
  });
97
92
  }
98
93
  /**
99
- * This method aims to sell rolls on behalf of the sender.
94
+ * Sells rolls on behalf of the sender.
100
95
  *
101
- * @param amount - The amount of rolls to be sold.
102
- * @param fee - The fee to be paid for the transaction execution by the node..
103
- * @returns An ITransactionDetails object. It contains the operationId on the network.
96
+ * @param amount - Number of rolls to sell.
97
+ * @param fee - Transaction execution fee (in smallest unit).
98
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
104
99
  */
105
100
  async sellRolls(amount, fee) {
106
101
  return new Promise((resolve, reject) => {
@@ -115,11 +110,13 @@ export class Account {
115
110
  });
116
111
  }
117
112
  /**
118
- * This method aims to transfer MAS on behalf of the sender to a recipient.
113
+ * Transfers MAS from the sender to a recipient.
119
114
  *
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
- * @returns An ITransactionDetails object. It contains the operationId on the network.
115
+ * @param amount - Amount of MAS to transfer (in smallest unit).
116
+ * @param recipientAddress - Recipient's address.
117
+ * @param fee - Transaction execution fee (in smallest unit).
118
+ *
119
+ * @returns A promise resolving to an ITransactionDetails containing the network operation ID.
123
120
  */
124
121
  async sendTransaction(amount, recipientAddress, fee) {
125
122
  return new Promise((resolve, reject) => {
@@ -135,24 +132,21 @@ export class Account {
135
132
  });
136
133
  }
137
134
  /**
138
- * This method aims to interact with a smart contract deployed on the MASSA blockchain.
135
+ * Interacts with a smart contract on the MASSA blockchain.
139
136
  *
140
137
  * @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.)
144
- *
145
- * @param contractAddress - The address of the smart contract.
146
- * @param functionName - The name of the function to be called.
147
- * @param parameter - The parameters as an Args object to be passed to the function.
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.
138
+ * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.
152
139
  *
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.
140
+ * @param contractAddress - Smart contract address.
141
+ * @param functionName - Function name to call.
142
+ * @param parameter - Function parameters.
143
+ * @param amount - Amount of MASSA coins to send (in smallest unit).
144
+ * @param fee - Transaction execution fee (in smallest unit).
145
+ * @param maxGas - Maximum gas for transaction execution.
146
+ * @param nonPersistentExecution - Whether to perform a dry run.
155
147
  *
148
+ * @returns A promise resolving to either:
149
+ * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).
156
150
  */
157
151
  async callSC(contractAddress, functionName, parameter, amount, fee, maxGas, nonPersistentExecution = false) {
158
152
  return new Promise((resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"file":"Account.js","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAuB,MAAM,IAAI,CAAC;AAO5D;;;;;;GAMG;AACH,MAAM,OAAO,OAAO;IACV,aAAa,CAAS;IACtB,QAAQ,CAAS;IACjB,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;IACH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,OAAO,CAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC9D,SAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,iBAAiB,CAAC,cAAc,EAChC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAA4B,EACpD,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM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CAAC,aAAa,EAC/B;gBACE,QAAQ,EAAE,IAAI,CAAC,KAAK;gBACpB,IAAI,EAAE,YAAY;gBAClB,EAAE,EAAE,eAAe;gBACnB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM;gBACd,sBAAsB,EAAE,sBAAsB;aACtB,EAC1B,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CACZ,sBAAsB;oBACpB,CAAC,CAAE,MAAyC;oBAC5C,CAAC,CAAE,MAA8B,CACpC,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import {\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n} from './AccountBalance';\nimport { IAccountSignOutput, IAccountSignRequest } from './AccountSign';\nimport { connector } from '../connector/Connector';\nimport { IAccountDetails } from './IAccountDetails';\nimport { AvailableCommands, ITransactionDetails } from '..';\nimport { IAccount } from './IAccount';\nimport { IAccountRollsRequest } from './IAccountRolls';\nimport { IAccountSendTransactionRequest } from './IAccountSendTransaction';\nimport { IAccountCallSCRequest } from './IAccountCallSCRequest';\nimport { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';\n\n/**\n * This module contains the Account class. It is responsible for representing an account in the wallet.\n *\n * @remarks\n * This class provides methods to interact with the account's {@link balance} and to {@link sign} messages.\n *\n */\nexport class Account implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n\n /**\n * This constructor takes an object of type IAccountDetails and a providerName string as its arguments.\n *\n * @param address - The address of the account.\n * @param name - The name of the account.\n * @param providerName - The name of the provider.\n * @returns An instance of the Account class.\n *\n * @remarks\n * - The Account constructor takes an object of type IAccountDetails and a providerName string as its arguments.\n * - The IAccountDetails object contains the account's address and name.\n * - The providerName string identifies the provider that is used to interact with the blockchain.\n */\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? '';\n this._providerName = providerName;\n }\n\n /**\n * @returns The address of the account.\n */\n public address(): string {\n return this._address;\n }\n\n /**\n * @returns The name of the account.\n */\n public name(): string {\n return this._name;\n }\n\n /**\n * @returns The name of the provider.\n */\n public providerName(): string {\n return this._providerName;\n }\n\n /**\n * This method aims to retrieve the account's balance.\n *\n * @returns A promise that resolves to an object of type IAccountBalanceResponse. It contains the account's balance.\n */\n public async balance(): Promise<IAccountBalanceResponse> {\n return new Promise<IAccountBalanceResponse>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBalance,\n { address: this._address } as IAccountBalanceRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountBalanceResponse);\n },\n );\n });\n }\n\n /**\n * This method aims to sign a message.\n *\n * @param data - The message to be signed.\n * @returns An IAccountSignOutput object. It contains the signature of the message.\n */\n public async sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput> {\n return new Promise<IAccountSignOutput>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSign,\n { address: this._address, data } as IAccountSignRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountSignOutput);\n },\n );\n });\n }\n\n /**\n * This method aims to buy rolls on behalf of the sender.\n *\n * @param amount - The amount of rolls to be purchased\n * @param fee - The fee to be paid for the transaction execution by the node..\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBuyRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n } as IAccountRollsRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to sell rolls on behalf of the sender.\n *\n * @param amount - The amount of rolls to be sold.\n * @param fee - The fee to be paid for the transaction execution by the node..\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSellRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n } as IAccountRollsRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to transfer MAS on behalf of the sender to a recipient.\n *\n * @param amount - The amount of MAS (in the smallest unit) to be transferred.\n * @param fee - The fee to be paid for the transaction execution (in the smallest unit).\n * @returns An ITransactionDetails object. It contains the operationId on the network.\n */\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSendTransaction,\n {\n amount: amount.toString(),\n recipientAddress,\n fee: fee.toString(),\n } as IAccountSendTransactionRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * This method aims to interact with a smart contract deployed on the MASSA blockchain.\n *\n * @remarks\n * If dryRun.dryRun is true, the method will dry run the smart contract call and return an\n * IContractReadOperationResponse object which contains all the information about the dry run\n * (state changes, gas used, etc.)\n *\n * @param contractAddress - The address of the smart contract.\n * @param functionName - The name of the function to be called.\n * @param parameter - The parameters as an Args object to be passed to the function.\n * @param amount - The amount of MASSA coins to be sent to the contract (in the smallest unit).\n * @param fee - The fee to be paid for the transaction execution (in the smallest unit).\n * @param maxGas - The maximum amount of gas to be used for the transaction execution.\n * @param nonPersistentExecution - The dryRun object to be passed to the function.\n *\n * @returns if 'nonPersistentExecution' is true, it returns an IContractReadOperationResponse object.\n * Otherwise, it returns an ITransactionDetails object which contains the operationId on the network.\n *\n */\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n return new Promise((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountCallSC,\n {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: parameter,\n coins: amount,\n fee: fee,\n maxGas: maxGas,\n nonPersistentExecution: nonPersistentExecution,\n } as IAccountCallSCRequest,\n (result, err) => {\n if (err) return reject(err);\n return resolve(\n nonPersistentExecution\n ? (result as IContractReadOperationResponse)\n : (result as ITransactionDetails),\n );\n },\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Account.js","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAuB,MAAM,IAAI,CAAC;AAI5D;;;GAGG;AACH,MAAM,OAAO,OAAO;IACV,aAAa,CAAS;IACtB,QAAQ,CAAS;IACjB,KAAK,CAAS;IAEtB;;;;;;;;;;OAUG;IAEH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO;QAClB,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;;;OAgBG;IACI,KAAK,CAAC,MAAM,CACjB,eAAuB,EACvB,YAAoB,EACpB,SAA4B,EAC5B,MAAc,EACd,GAAW,EACX,MAAc,EACd,sBAAsB,GAAG,KAAK;QAE9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,SAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,iBAAiB,CAAC,aAAa,EAC/B;gBACE,QAAQ,EAAE,IAAI,CAAC,KAAK;gBACpB,IAAI,EAAE,YAAY;gBAClB,EAAE,EAAE,eAAe;gBACnB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,GAAG;gBACR,MAAM,EAAE,MAAM;gBACd,sBAAsB,EAAE,sBAAsB;aAC/C,EACD,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CACZ,sBAAsB;oBACpB,CAAC,CAAE,MAAyC;oBAC5C,CAAC,CAAE,MAA8B,CACpC,CAAC;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { IAccountBalanceResponse } from './AccountBalance';\nimport { IAccountSignOutput } from './AccountSign';\nimport { connector } from '../connector/Connector';\nimport { IAccountDetails } from './IAccountDetails';\nimport { AvailableCommands, ITransactionDetails } from '..';\nimport { IAccount } from './IAccount';\nimport { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';\n\n/**\n * The Account class represents a wallet account. It provides methods for interacting\n * with the account's balance and for signing messages.\n */\nexport class Account implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n\n /**\n * Initializes a new instance of the Account class.\n *\n * @param address - Account address.\n * @param name - Account name.\n * @param providerName - Blockchain provider name.\n *\n * @remarks\n * - Utilizes IAccountDetails for account information and a providerName string for blockchain interaction.\n * - The providerName string identifies the provider that is used to interact with the blockchain.\n */\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? '';\n this._providerName = providerName;\n }\n\n /**\n * @returns The address of the account.\n */\n public address(): string {\n return this._address;\n }\n\n /**\n * @returns The name of the account.\n */\n public name(): string {\n return this._name;\n }\n\n /**\n * @returns The name of the provider.\n */\n public providerName(): string {\n return this._providerName;\n }\n\n /**\n * Retrieves the account balance.\n *\n * @returns A promise that resolves to an object of type IAccountBalanceResponse.\n */\n public async balance(): Promise<IAccountBalanceResponse> {\n return new Promise<IAccountBalanceResponse>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBalance,\n { address: this._address },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountBalanceResponse);\n },\n );\n });\n }\n\n /**\n * Signs a provided message.\n *\n * @param data - Message to sign.\n * @returns An IAccountSignOutput object which contains the signature and the public key.\n */\n public async sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput> {\n return new Promise<IAccountSignOutput>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSign,\n { address: this._address, data },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as IAccountSignOutput);\n },\n );\n });\n }\n\n /**\n * Purchases rolls for the sender.\n *\n * @param amount - Number of rolls to purchase.\n * @param fee - Transaction execution fee (in smallest unit).\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountBuyRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Sells rolls on behalf of the sender.\n *\n * @param amount - Number of rolls to sell.\n * @param fee - Transaction execution fee (in smallest unit).\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSellRolls,\n {\n amount: amount.toString(),\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Transfers MAS from the sender to a recipient.\n *\n * @param amount - Amount of MAS to transfer (in smallest unit).\n * @param recipientAddress - Recipient's address.\n * @param fee - Transaction execution fee (in smallest unit).\n *\n * @returns A promise resolving to an ITransactionDetails containing the network operation ID.\n */\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n return new Promise<ITransactionDetails>((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountSendTransaction,\n {\n amount: amount.toString(),\n recipientAddress,\n fee: fee.toString(),\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(result as ITransactionDetails);\n },\n );\n });\n }\n\n /**\n * Interacts with a smart contract on the MASSA blockchain.\n *\n * @remarks\n * If dryRun is true, performs a dry run and returns an IContractReadOperationResponse with dry run details.\n *\n * @param contractAddress - Smart contract address.\n * @param functionName - Function name to call.\n * @param parameter - Function parameters.\n * @param amount - Amount of MASSA coins to send (in smallest unit).\n * @param fee - Transaction execution fee (in smallest unit).\n * @param maxGas - Maximum gas for transaction execution.\n * @param nonPersistentExecution - Whether to perform a dry run.\n *\n * @returns A promise resolving to either:\n * IContractReadOperationResponse (for dry runs) or ITransactionDetails (for actual transactions).\n */\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n return new Promise((resolve, reject) => {\n connector.sendMessageToContentScript(\n this._providerName,\n AvailableCommands.AccountCallSC,\n {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: parameter,\n coins: amount,\n fee: fee,\n maxGas: maxGas,\n nonPersistentExecution: nonPersistentExecution,\n },\n (result, err) => {\n if (err) return reject(err);\n return resolve(\n nonPersistentExecution\n ? (result as IContractReadOperationResponse)\n : (result as ITransactionDetails),\n );\n },\n );\n });\n }\n}\n"]}
@@ -1,11 +1,16 @@
1
1
  /**
2
- * This interface represents the request object of the AccountBalance command.
2
+ * Represents the request for an AccountBalance command.
3
+ *
4
+ * address - The account address.
3
5
  */
4
6
  export interface IAccountBalanceRequest {
5
7
  address: string;
6
8
  }
7
9
  /**
8
- * This interface represents the response object of the AccountBalance command sent by the content script.
10
+ * Represents the response from an AccountBalance command.
11
+ *
12
+ * finalBalance - The account's final confirmed balance.
13
+ * candidateBalance - The account's pending balance.
9
14
  */
10
15
  export interface IAccountBalanceResponse {
11
16
  finalBalance: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
1
+ {"version":3,"file":"AccountBalance.d.ts","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object of the AccountBalance command.\n */\nexport interface IAccountBalanceRequest {\n address: string;\n}\n\n/**\n * This interface represents the response object of the AccountBalance command sent by the content script.\n */\nexport interface IAccountBalanceResponse {\n finalBalance: string;\n candidateBalance: string;\n}\n"]}
1
+ {"version":3,"file":"AccountBalance.js","sourceRoot":"","sources":["../../../src/account/AccountBalance.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents the request for an AccountBalance command.\n *\n * address - The account address.\n */\nexport interface IAccountBalanceRequest {\n address: string;\n}\n\n/**\n * Represents the response from an AccountBalance command.\n *\n * finalBalance - The account's final confirmed balance.\n * candidateBalance - The account's pending balance.\n */\nexport interface IAccountBalanceResponse {\n finalBalance: string;\n candidateBalance: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BearbyAccount.d.ts","sourceRoot":"","sources":["../../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,eAAe,EAEhB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAO5D;;GAEG;AACH,eAAO,MAAM,eAAe,sCAAsC,CAAC;AAEnE,oBAAY,cAAc;IACxB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,SAAS,IAAA;IACT,MAAM,IAAA;CACP;AAED;;GAEG;AACH,oBAAY,eAAe;IACzB,WAAW,IAAI;IACf,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,SAA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KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO;YACL,WAAW,EAAE,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n ArgTypes,\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\nimport { ITransactionDetails } from '..';\nimport {\n IAccountBalanceResponse,\n IAccountDetails,\n IAccountSignResponse,\n} from '../account';\nimport { IAccount } from '../account/IAccount';\nimport { web3 } from '@hicaru/bearby.js';\nimport {\n postRequest,\n JsonRpcResponseData,\n} from '../massaStation/RequestHandler';\nimport { BalanceResponse } from './BalanceResponse';\nimport { NodeStatus } from './NodeStatus';\nimport { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';\nimport axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';\nimport { decode } from 'bs58check';\nimport { IAccountSignOutput } from '../account/AccountSign';\nimport { isArrayOfNumbers } from '../utils/typeCheck';\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * The RPC we are using to query the node\n */\nexport const PUBLIC_NODE_RPC = 'https://buildnet.massa.net/api/v2';\n\nexport enum OperationsType {\n Payment,\n RollBuy,\n RollSell,\n ExecuteSC,\n CallSC,\n}\n\n/**\n * Associates an operation type with a number.\n */\nexport enum OperationTypeId {\n Transaction = 0,\n RollBuy = 1,\n RollSell = 2,\n ExecuteSC = 3,\n CallSC = 4,\n}\n\nconst requestHeaders = {\n Accept:\n 'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Content-Type': 'application/json',\n} as AxiosRequestHeaders;\n\nexport class BearbyAccount implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n private _nodeUrl = PUBLIC_NODE_RPC;\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? 'Bearby_account';\n this._providerName = providerName;\n }\n\n public address(): string {\n return this._address;\n }\n\n public name(): string {\n return this._name;\n }\n\n public providerName(): string {\n return this._providerName;\n }\n\n public async connect() {\n try {\n await web3.wallet.connect();\n } catch (ex) {\n console.log('Bearby connection error: ', ex);\n }\n }\n\n // needs testing\n public async balance(): Promise<IAccountBalanceResponse> {\n await this.connect();\n // Not available on bearby. we have to manually call the api\n const body = {\n jsonrpc: '2.0',\n method: 'get_addresses',\n params: [[this._address]],\n id: 0,\n };\n\n const addressInfos = await postRequest<BalanceResponse>(\n PUBLIC_NODE_RPC,\n body,\n );\n\n if (addressInfos.isError || addressInfos.error) {\n throw addressInfos.error.message;\n }\n return {\n finalBalance: addressInfos.result.result[0].final_balance,\n candidateBalance: addressInfos.result.result[0].candidate_balance,\n } as IAccountBalanceResponse;\n }\n\n // need testing\n public async sign(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignOutput> {\n await this.connect();\n\n let strData: string;\n if (data instanceof Uint8Array) {\n strData = new TextDecoder().decode(data);\n }\n if (data instanceof Buffer) {\n strData = data.toString();\n }\n const signature = await web3.wallet.signMessage(strData);\n return {\n publicKey: signature.publicKey,\n base58Encoded: signature.signature,\n };\n }\n\n // need testing\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.buyRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n // need testing\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.sellRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n\n const operationId = await web3.massa.payment(\n amount.toString(),\n recipientAddress,\n );\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Args | Uint8Array,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n await this.connect();\n if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n\n const operationId = await web3.contract.call({\n maxGas: Number(maxGas),\n coins: Number(amount),\n fee: Number(fee),\n targetAddress: contractAddress,\n functionName: functionName,\n unsafeParameters: isArrayOfNumbers(parameter)\n ? (parameter as Uint8Array)\n : ((parameter as Args).serialize() as unknown as Uint8Array),\n });\n\n return { operationId };\n }\n\n /**\n * Retrieves the node's status.\n *\n * @remarks\n * The returned information includes:\n * - Whether the node is reachable\n * - The number of connected peers\n * - The node's version\n * - The node's configuration parameters\n *\n * @returns A promise that resolves to the node's status information.\n */\n public async getNodeStatus(): Promise<NodeStatus> {\n const jsonRpcRequestMethod = JSON_RPC_REQUEST_METHOD.GET_STATUS;\n return await this.sendJsonRPCRequest<NodeStatus>(jsonRpcRequestMethod, []);\n }\n\n /**\n * Sends a post JSON rpc request to the node.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @throws An error if the rpc method returns an error.\n *\n * @returns A promise that resolves as the result of the rpc method.\n */\n protected async sendJsonRPCRequest<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<T> {\n let resp: JsonRpcResponseData<T> = null;\n resp = await this.promisifyJsonRpcCall(resource, params);\n\n // in case of rpc error, rethrow the error.\n if (resp.isError || resp.error) {\n throw resp.error;\n }\n\n return resp.result;\n }\n\n /**\n * Converts a json rpc call to a promise that resolves as a JsonRpcResponseData\n *\n * @privateRemarks\n * If there is an error while sending the request, the function catches the error, the isError\n * property is set to true, the result property set to null, and the error property set to a\n * new Error object with a message indicating that there was an error.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @returns A promise that resolves as a JsonRpcResponseData.\n */\n private async promisifyJsonRpcCall<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<JsonRpcResponseData<T>> {\n let resp: AxiosResponse<JsonRpcResponseData<T>> = null;\n\n const body = {\n jsonrpc: '2.0',\n method: resource,\n params: params,\n id: 0,\n };\n\n try {\n resp = await axios.post(this._nodeUrl, body, { headers: requestHeaders });\n } catch (ex) {\n return {\n isError: true,\n result: null,\n error: new Error('JSON.parse error: ' + String(ex)),\n } as JsonRpcResponseData<T>;\n }\n\n const responseData: JsonRpcResponseData<T> = resp.data;\n\n if (responseData.error) {\n return {\n isError: true,\n result: null,\n error: new Error(responseData.error.message),\n } as JsonRpcResponseData<T>;\n }\n\n return {\n isError: false,\n result: responseData.result as T,\n error: null,\n } as JsonRpcResponseData<T>;\n }\n\n public async nonPersistentCallSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n ): Promise<IContractReadOperationResponse> {\n // not clean but bearby doesn't allow us to get its node urls\n const node = PUBLIC_NODE_RPC;\n // Gas amount check\n if (maxGas > MAX_READ_BLOCK_GAS) {\n throw new Error(\n `\n The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of \n ${MAX_READ_BLOCK_GAS.toString()}\n `,\n );\n }\n\n // convert parameter to an array of numbers\n let argumentArray = [];\n if (parameter instanceof Uint8Array) {\n argumentArray = Array.from(parameter);\n } else {\n argumentArray = Array.from(parameter.serialize());\n }\n // setup the request body\n const data = {\n max_gas: Number(maxGas),\n target_address: contractAddress,\n target_function: functionName,\n parameter: argumentArray,\n caller_address: this._address,\n coins: Number(amount),\n fee: Number(fee),\n };\n const body = [\n {\n jsonrpc: '2.0',\n method: 'execute_read_only_call',\n params: [[data]],\n id: 0,\n },\n ];\n // returns operation ids\n let jsonRpcCallResult: Array<IContractReadOperationData> = [];\n try {\n let resp = await postRequest<Array<IContractReadOperationData>>(\n node,\n body,\n );\n if (resp.isError || resp.error) {\n throw resp.error.message;\n }\n jsonRpcCallResult = resp.result;\n } catch (ex) {\n throw new Error(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n }\n if (jsonRpcCallResult.length <= 0) {\n throw new Error(\n `Read operation bad response. No results array in json rpc response. Inspect smart contract`,\n );\n }\n if (jsonRpcCallResult[0].result.Error) {\n throw new Error(jsonRpcCallResult[0].result.Error);\n }\n return {\n returnValue: new Uint8Array(jsonRpcCallResult[0].result[0].result.Ok),\n info: jsonRpcCallResult[0],\n };\n }\n}\n"]}
1
+ {"version":3,"file":"BearbyAccount.js","sourceRoot":"","sources":["../../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EACL,WAAW,GAEZ,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAA6C,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,mCAAmC,CAAC;AAEnE,MAAM,CAAN,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,yDAAO,CAAA;IACP,yDAAO,CAAA;IACP,2DAAQ,CAAA;IACR,6DAAS,CAAA;IACT,uDAAM,CAAA;AACR,CAAC,EANW,cAAc,KAAd,cAAc,QAMzB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,mEAAe,CAAA;IACf,2DAAW,CAAA;IACX,6DAAY,CAAA;IACZ,+DA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L,CAAC;YACF,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,EAAE;gBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;aAC1B;YACD,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC;SACjC;QAAC,OAAO,EAAE,EAAE;YACX,MAAM,IAAI,KAAK,CACb,sEAAsE,EAAE,EAAE,CAC3E,CAAC;SACH;QACD,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CACb,4FAA4F,CAC7F,CAAC;SACH;QACD,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpD;QACD,OAAO;YACL,WAAW,EAAE,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\nimport { ITransactionDetails } from '..';\nimport { IAccountBalanceResponse, IAccountDetails } from '../account';\nimport { IAccount } from '../account/IAccount';\nimport { web3 } from '@hicaru/bearby.js';\nimport {\n postRequest,\n JsonRpcResponseData,\n} from '../massaStation/RequestHandler';\nimport { BalanceResponse } from './BalanceResponse';\nimport { NodeStatus } from './NodeStatus';\nimport { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';\nimport axios, { AxiosRequestHeaders, AxiosResponse } from 'axios';\nimport { IAccountSignOutput } from '../account/AccountSign';\nimport { isArrayOfNumbers } from '../utils/typeCheck';\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * The RPC we are using to query the node\n */\nexport const PUBLIC_NODE_RPC = 'https://buildnet.massa.net/api/v2';\n\nexport enum OperationsType {\n Payment,\n RollBuy,\n RollSell,\n ExecuteSC,\n CallSC,\n}\n\n/**\n * Associates an operation type with a number.\n */\nexport enum OperationTypeId {\n Transaction = 0,\n RollBuy = 1,\n RollSell = 2,\n ExecuteSC = 3,\n CallSC = 4,\n}\n\nconst requestHeaders = {\n Accept:\n 'application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',\n 'Content-Type': 'application/json',\n} as AxiosRequestHeaders;\n\nexport class BearbyAccount implements IAccount {\n private _providerName: string;\n private _address: string;\n private _name: string;\n private _nodeUrl = PUBLIC_NODE_RPC;\n\n public constructor({ address, name }: IAccountDetails, providerName: string) {\n this._address = address;\n this._name = name ?? 'Bearby_account';\n this._providerName = providerName;\n }\n\n public address(): string {\n return this._address;\n }\n\n public name(): string {\n return this._name;\n }\n\n public providerName(): string {\n return this._providerName;\n }\n\n public async connect() {\n try {\n await web3.wallet.connect();\n } catch (ex) {\n console.log('Bearby connection error: ', ex);\n }\n }\n\n // needs testing\n public async balance(): Promise<IAccountBalanceResponse> {\n await this.connect();\n // Not available on bearby. we have to manually call the api\n const body = {\n jsonrpc: '2.0',\n method: 'get_addresses',\n params: [[this._address]],\n id: 0,\n };\n\n const addressInfos = await postRequest<BalanceResponse>(\n PUBLIC_NODE_RPC,\n body,\n );\n\n if (addressInfos.isError || addressInfos.error) {\n throw addressInfos.error.message;\n }\n return {\n finalBalance: addressInfos.result.result[0].final_balance,\n candidateBalance: addressInfos.result.result[0].candidate_balance,\n } as IAccountBalanceResponse;\n }\n\n // need testing\n public async sign(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignOutput> {\n await this.connect();\n\n let strData: string;\n if (data instanceof Uint8Array) {\n strData = new TextDecoder().decode(data);\n }\n if (data instanceof Buffer) {\n strData = data.toString();\n }\n const signature = await web3.wallet.signMessage(strData);\n return {\n publicKey: signature.publicKey,\n base58Encoded: signature.signature,\n };\n }\n\n // need testing\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.buyRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n // need testing\n public async sellRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const operationId = await web3.massa.sellRolls(amount.toString());\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n\n const operationId = await web3.massa.payment(\n amount.toString(),\n recipientAddress,\n );\n\n return {\n operationId,\n } as ITransactionDetails;\n }\n\n public async callSC(\n contractAddress: string,\n functionName: string,\n parameter: Args | Uint8Array,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution = false,\n ): Promise<ITransactionDetails | IContractReadOperationResponse> {\n await this.connect();\n if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n\n const operationId = await web3.contract.call({\n maxGas: Number(maxGas),\n coins: Number(amount),\n fee: Number(fee),\n targetAddress: contractAddress,\n functionName: functionName,\n unsafeParameters: isArrayOfNumbers(parameter)\n ? (parameter as Uint8Array)\n : ((parameter as Args).serialize() as unknown as Uint8Array),\n });\n\n return { operationId };\n }\n\n /**\n * Retrieves the node's status.\n *\n * @remarks\n * The returned information includes:\n * - Whether the node is reachable\n * - The number of connected peers\n * - The node's version\n * - The node's configuration parameters\n *\n * @returns A promise that resolves to the node's status information.\n */\n public async getNodeStatus(): Promise<NodeStatus> {\n const jsonRpcRequestMethod = JSON_RPC_REQUEST_METHOD.GET_STATUS;\n return await this.sendJsonRPCRequest<NodeStatus>(jsonRpcRequestMethod, []);\n }\n\n /**\n * Sends a post JSON rpc request to the node.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @throws An error if the rpc method returns an error.\n *\n * @returns A promise that resolves as the result of the rpc method.\n */\n protected async sendJsonRPCRequest<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<T> {\n let resp: JsonRpcResponseData<T> = null;\n resp = await this.promisifyJsonRpcCall(resource, params);\n\n // in case of rpc error, rethrow the error.\n if (resp.isError || resp.error) {\n throw resp.error;\n }\n\n return resp.result;\n }\n\n /**\n * Converts a json rpc call to a promise that resolves as a JsonRpcResponseData\n *\n * @privateRemarks\n * If there is an error while sending the request, the function catches the error, the isError\n * property is set to true, the result property set to null, and the error property set to a\n * new Error object with a message indicating that there was an error.\n *\n * @param resource - The rpc method to call.\n * @param params - The parameters to pass to the rpc method.\n *\n * @returns A promise that resolves as a JsonRpcResponseData.\n */\n private async promisifyJsonRpcCall<T>(\n resource: JSON_RPC_REQUEST_METHOD,\n params: object,\n ): Promise<JsonRpcResponseData<T>> {\n let resp: AxiosResponse<JsonRpcResponseData<T>> = null;\n\n const body = {\n jsonrpc: '2.0',\n method: resource,\n params: params,\n id: 0,\n };\n\n try {\n resp = await axios.post(this._nodeUrl, body, { headers: requestHeaders });\n } catch (ex) {\n return {\n isError: true,\n result: null,\n error: new Error('JSON.parse error: ' + String(ex)),\n } as JsonRpcResponseData<T>;\n }\n\n const responseData: JsonRpcResponseData<T> = resp.data;\n\n if (responseData.error) {\n return {\n isError: true,\n result: null,\n error: new Error(responseData.error.message),\n } as JsonRpcResponseData<T>;\n }\n\n return {\n isError: false,\n result: responseData.result as T,\n error: null,\n } as JsonRpcResponseData<T>;\n }\n\n public async nonPersistentCallSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n ): Promise<IContractReadOperationResponse> {\n // not clean but bearby doesn't allow us to get its node urls\n const node = PUBLIC_NODE_RPC;\n // Gas amount check\n if (maxGas > MAX_READ_BLOCK_GAS) {\n throw new Error(\n `\n The gas submitted ${maxGas.toString()} exceeds the max. allowed block gas of \n ${MAX_READ_BLOCK_GAS.toString()}\n `,\n );\n }\n\n // convert parameter to an array of numbers\n let argumentArray = [];\n if (parameter instanceof Uint8Array) {\n argumentArray = Array.from(parameter);\n } else {\n argumentArray = Array.from(parameter.serialize());\n }\n // setup the request body\n const data = {\n max_gas: Number(maxGas),\n target_address: contractAddress,\n target_function: functionName,\n parameter: argumentArray,\n caller_address: this._address,\n coins: Number(amount),\n fee: Number(fee),\n };\n const body = [\n {\n jsonrpc: '2.0',\n method: 'execute_read_only_call',\n params: [[data]],\n id: 0,\n },\n ];\n // returns operation ids\n let jsonRpcCallResult: Array<IContractReadOperationData> = [];\n try {\n let resp = await postRequest<Array<IContractReadOperationData>>(\n node,\n body,\n );\n if (resp.isError || resp.error) {\n throw resp.error.message;\n }\n jsonRpcCallResult = resp.result;\n } catch (ex) {\n throw new Error(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n }\n if (jsonRpcCallResult.length <= 0) {\n throw new Error(\n `Read operation bad response. No results array in json rpc response. Inspect smart contract`,\n );\n }\n if (jsonRpcCallResult[0].result.Error) {\n throw new Error(jsonRpcCallResult[0].result.Error);\n }\n return {\n returnValue: new Uint8Array(jsonRpcCallResult[0].result[0].result.Ok),\n info: jsonRpcCallResult[0],\n };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/wallet-provider",
3
- "version": "1.4.2-dev.20230926140020",
3
+ "version": "1.4.2-dev.20230929102811",
4
4
  "description": "massa's wallet provider",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",