@massalabs/wallet-provider 1.3.3-dev.20230823143856 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle.js CHANGED
@@ -5874,7 +5874,7 @@ class Account {
5874
5874
  * This method aims to sign a message.
5875
5875
  *
5876
5876
  * @param data - The message to be signed.
5877
- * @returns An IAccountSignResponse object. It contains the signature of the message.
5877
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
5878
5878
  */
5879
5879
  async sign(data) {
5880
5880
  return new Promise((resolve, reject) => {
@@ -52,7 +52,7 @@ export declare class Account implements IAccount {
52
52
  * This method aims to sign a message.
53
53
  *
54
54
  * @param data - The message to be signed.
55
- * @returns An IAccountSignResponse object. It contains the signature of the message.
55
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
56
56
  */
57
57
  sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
58
  /**
@@ -62,7 +62,7 @@ export class Account {
62
62
  * This method aims to sign a message.
63
63
  *
64
64
  * @param data - The message to be signed.
65
- * @returns An IAccountSignResponse object. It contains the signature of the message.
65
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
66
66
  */
67
67
  async sign(data) {
68
68
  return new Promise((resolve, reject) => {
@@ -52,7 +52,7 @@ export declare class Account implements IAccount {
52
52
  * This method aims to sign a message.
53
53
  *
54
54
  * @param data - The message to be signed.
55
- * @returns An IAccountSignResponse object. It contains the signature of the message.
55
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
56
56
  */
57
57
  sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
58
  /**
@@ -65,7 +65,7 @@ class Account {
65
65
  * This method aims to sign a message.
66
66
  *
67
67
  * @param data - The message to be signed.
68
- * @returns An IAccountSignResponse object. It contains the signature of the message.
68
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
69
69
  */
70
70
  async sign(data) {
71
71
  return new Promise((resolve, reject) => {
@@ -1 +1 @@
1
- {"version":3,"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AC;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 IAccountSignResponse 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":";;;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;Q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AAG;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;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"]}
@@ -52,7 +52,7 @@ export declare class Account implements IAccount {
52
52
  * This method aims to sign a message.
53
53
  *
54
54
  * @param data - The message to be signed.
55
- * @returns An IAccountSignResponse object. It contains the signature of the message.
55
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
56
56
  */
57
57
  sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
58
  /**
@@ -65,7 +65,7 @@ export class Account {
65
65
  * This method aims to sign a message.
66
66
  *
67
67
  * @param data - The message to be signed.
68
- * @returns An IAccountSignResponse object. It contains the signature of the message.
68
+ * @returns An IAccountSignOutput object. It contains the signature of the message.
69
69
  */
70
70
  async sign(data) {
71
71
  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,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AgB;gBAChB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;aACc,EACnC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;gBACd,IAAI,GAAG;oBAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,MAA6B,CAAC,CAAC;YAChD,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;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;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 IAccountSignResponse 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":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAuB,MAAM,IAAI,CAAC;AAO5D;;;;;;GAMG;AACH,MAAM,OAA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C5C,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/wallet-provider",
3
- "version": "1.3.3-dev.20230823143856",
3
+ "version": "1.3.3",
4
4
  "description": "massa's wallet provider",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",