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

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.
Files changed (49) hide show
  1. package/bundle.js +4 -5
  2. package/bundle.min.js +1 -1
  3. package/dist/account/Account.d.ts +2 -2
  4. package/dist/account/Account.d.ts.map +1 -1
  5. package/dist/account/AccountSign.d.ts +8 -1
  6. package/dist/account/AccountSign.d.ts.map +1 -1
  7. package/dist/account/IAccount.d.ts +2 -2
  8. package/dist/account/IAccount.d.ts.map +1 -1
  9. package/dist/bearbyWallet/BearbyAccount.d.ts +3 -2
  10. package/dist/bearbyWallet/BearbyAccount.d.ts.map +1 -1
  11. package/dist/bearbyWallet/BearbyAccount.js +1 -2
  12. package/dist/cmd/account/Account.d.ts +2 -2
  13. package/dist/cmd/account/Account.d.ts.map +1 -1
  14. package/dist/cmd/account/Account.js.map +1 -1
  15. package/dist/cmd/account/AccountSign.d.ts +8 -1
  16. package/dist/cmd/account/AccountSign.d.ts.map +1 -1
  17. package/dist/cmd/account/AccountSign.js.map +1 -1
  18. package/dist/cmd/account/IAccount.d.ts +2 -2
  19. package/dist/cmd/account/IAccount.d.ts.map +1 -1
  20. package/dist/cmd/account/IAccount.js.map +1 -1
  21. package/dist/cmd/bearbyWallet/BearbyAccount.d.ts +3 -2
  22. package/dist/cmd/bearbyWallet/BearbyAccount.d.ts.map +1 -1
  23. package/dist/cmd/bearbyWallet/BearbyAccount.js +1 -2
  24. package/dist/cmd/bearbyWallet/BearbyAccount.js.map +1 -1
  25. package/dist/cmd/massaStation/MassaStationAccount.d.ts +3 -2
  26. package/dist/cmd/massaStation/MassaStationAccount.d.ts.map +1 -1
  27. package/dist/cmd/massaStation/MassaStationAccount.js +3 -3
  28. package/dist/cmd/massaStation/MassaStationAccount.js.map +1 -1
  29. package/dist/esm/account/Account.d.ts +2 -2
  30. package/dist/esm/account/Account.d.ts.map +1 -1
  31. package/dist/esm/account/Account.js.map +1 -1
  32. package/dist/esm/account/AccountSign.d.ts +8 -1
  33. package/dist/esm/account/AccountSign.d.ts.map +1 -1
  34. package/dist/esm/account/AccountSign.js.map +1 -1
  35. package/dist/esm/account/IAccount.d.ts +2 -2
  36. package/dist/esm/account/IAccount.d.ts.map +1 -1
  37. package/dist/esm/account/IAccount.js.map +1 -1
  38. package/dist/esm/bearbyWallet/BearbyAccount.d.ts +3 -2
  39. package/dist/esm/bearbyWallet/BearbyAccount.d.ts.map +1 -1
  40. package/dist/esm/bearbyWallet/BearbyAccount.js +1 -2
  41. package/dist/esm/bearbyWallet/BearbyAccount.js.map +1 -1
  42. package/dist/esm/massaStation/MassaStationAccount.d.ts +3 -2
  43. package/dist/esm/massaStation/MassaStationAccount.d.ts.map +1 -1
  44. package/dist/esm/massaStation/MassaStationAccount.js +3 -3
  45. package/dist/esm/massaStation/MassaStationAccount.js.map +1 -1
  46. package/dist/massaStation/MassaStationAccount.d.ts +3 -2
  47. package/dist/massaStation/MassaStationAccount.d.ts.map +1 -1
  48. package/dist/massaStation/MassaStationAccount.js +3 -3
  49. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/account/Account.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAqB,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE7E;;;;;;GAMG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,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MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;CA0BjE"}
@@ -11,6 +11,13 @@ export interface IAccountSignRequest {
11
11
  */
12
12
  export interface IAccountSignResponse {
13
13
  publicKey: string;
14
- signature: Uint8Array;
14
+ signature: string;
15
+ }
16
+ /**
17
+ * This interface represents the output of a sign() method
18
+ */
19
+ export interface IAccountSignOutput {
20
+ publicKey: string;
21
+ base58Encoded: string;
15
22
  }
16
23
  //# sourceMappingURL=AccountSign.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSign.d.ts","sourceRoot":"","sources":["../../src/account/AccountSign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;CACvB"}
1
+ {"version":3,"file":"AccountSign.d.ts","sourceRoot":"","sources":["../../src/account/AccountSign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { ITransactionDetails } from '..';
3
3
  import { IAccountBalanceResponse } from './AccountBalance';
4
- import { IAccountSignResponse } from './AccountSign';
4
+ import { IAccountSignOutput } from './AccountSign';
5
5
  import { Args } from '@massalabs/web3-utils';
6
6
  /**
7
7
  * This interface represents an Account object.
@@ -12,7 +12,7 @@ export interface IAccount {
12
12
  name(): string;
13
13
  providerName(): string;
14
14
  balance(): Promise<IAccountBalanceResponse>;
15
- sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;
15
+ sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;
16
16
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
17
17
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
18
18
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
@@ -1 +1 @@
1
- {"version":3,"file":"IAccount.d.ts","sourceRoot":"","sources":["../../src/account/IAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;IACf,YAAY,IAAI,MAAM,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrE,eAAe,CACb,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EA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AI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,CAAC,EAAE,OAAO,OAChC;CACH"}
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
3
3
  import { ITransactionDetails } from '..';
4
- import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse } from '../account';
4
+ import { IAccountBalanceResponse, IAccountDetails } from '../account';
5
5
  import { IAccount } from '../account/IAccount';
6
6
  import { NodeStatus } from './NodeStatus';
7
7
  import { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';
8
+ import { IAccountSignOutput } from '../account/AccountSign';
8
9
  /**
9
10
  * The RPC we are using to query the node
10
11
  */
@@ -37,7 +38,7 @@ export declare class BearbyAccount implements IAccount {
37
38
  providerName(): string;
38
39
  connect(): Promise<void>;
39
40
  balance(): Promise<IAccountBalanceResponse>;
40
- sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;
41
+ sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;
41
42
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
42
43
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
43
44
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
@@ -1 +1 @@
1
- {"version":3,"file":"BearbyAccount.d.ts","sourceRoot":"","sources":["../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,OAAO,EAAE,UAAU,EAAE,M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,uBAAuB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC;IAYb;;;;;;;;;;;;OAYG;YACW,oBAAoB;IAwCrB,mBAAmB,CAC9B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,8BAA8B,CAAC;CAmE3C"}
@@ -2,7 +2,6 @@ import { web3 } from '@hicaru/bearby.js';
2
2
  import { postRequest, } from '../massaStation/RequestHandler';
3
3
  import { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';
4
4
  import axios from 'axios';
5
- import { decode } from 'bs58check';
6
5
  /**
7
6
  * The maximum allowed gas for a read operation
8
7
  */
@@ -90,7 +89,7 @@ export class BearbyAccount {
90
89
  const signature = await web3.wallet.signMessage(strData);
91
90
  return {
92
91
  publicKey: signature.publicKey,
93
- signature: decode(signature.signature),
92
+ base58Encoded: signature.signature,
94
93
  };
95
94
  }
96
95
  // need testing
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { IAccountBalanceResponse } from './AccountBalance';
3
- import { IAccountSignResponse } from './AccountSign';
3
+ import { IAccountSignOutput } from './AccountSign';
4
4
  import { IAccountDetails } from './IAccountDetails';
5
5
  import { ITransactionDetails } from '..';
6
6
  import { IAccount } from './IAccount';
@@ -54,7 +54,7 @@ export declare class Account implements IAccount {
54
54
  * @param data - The message to be signed.
55
55
  * @returns An IAccountSignResponse object. It contains the signature of the message.
56
56
  */
57
- sign(data: Buffer | Uint8Array): Promise<IAccountSignResponse>;
57
+ sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
58
  /**
59
59
  * This method aims to buy rolls on behalf of the sender.
60
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":";A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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,qBAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,qBAAiB,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;AA7ND,0BA6NC","sourcesContent":["import {\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n} from './AccountBalance';\nimport { IAccountSignRequest, IAccountSignResponse } 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<IAccountSignResponse> {\n return new Promise<IAccountSignResponse>((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 IAccountSignResponse);\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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AAG,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,qBAAS,CAAC,0BAA0B,CAClC,IAAI,CAAC,aAAa,EAClB,qBAAiB,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;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"]}
@@ -11,6 +11,13 @@ export interface IAccountSignRequest {
11
11
  */
12
12
  export interface IAccountSignResponse {
13
13
  publicKey: string;
14
- signature: Uint8Array;
14
+ signature: string;
15
+ }
16
+ /**
17
+ * This interface represents the output of a sign() method
18
+ */
19
+ export interface IAccountSignOutput {
20
+ publicKey: string;
21
+ base58Encoded: string;
15
22
  }
16
23
  //# sourceMappingURL=AccountSign.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSign.d.ts","sourceRoot":"","sources":["../../../src/account/AccountSign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,UAAU,CAAC;CACvB"}
1
+ {"version":3,"file":"AccountSign.d.ts","sourceRoot":"","sources":["../../../src/account/AccountSign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccountSign.js","sourceRoot":"","sources":["../../../src/account/AccountSign.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object for the signing operation sent to the content script.\n */\nexport interface IAccountSignRequest {\n address: string;\n data: Uint8Array;\n}\n\n/**\n * This interface represents the response object containing the signed message data, which is sent by the content script\n * after the signing operation.\n */\nexport interface IAccountSignResponse {\n publicKey: string;\n signature: Uint8Array;\n}\n"]}
1
+ {"version":3,"file":"AccountSign.js","sourceRoot":"","sources":["../../../src/account/AccountSign.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object for the signing operation sent to the content script.\n */\nexport interface IAccountSignRequest {\n address: string;\n data: Uint8Array;\n}\n\n/**\n * This interface represents the response object containing the signed message data, which is sent by the content script\n * after the signing operation.\n */\nexport interface IAccountSignResponse {\n publicKey: string;\n signature: string;\n}\n\n/**\n * This interface represents the output of a sign() method\n */\nexport interface IAccountSignOutput {\n publicKey: string;\n base58Encoded: string;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { ITransactionDetails } from '..';
3
3
  import { IAccountBalanceResponse } from './AccountBalance';
4
- import { IAccountSignResponse } from './AccountSign';
4
+ import { IAccountSignOutput } from './AccountSign';
5
5
  import { Args } from '@massalabs/web3-utils';
6
6
  /**
7
7
  * This interface represents an Account object.
@@ -12,7 +12,7 @@ export interface IAccount {
12
12
  name(): string;
13
13
  providerName(): string;
14
14
  balance(): Promise<IAccountBalanceResponse>;
15
- sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;
15
+ sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;
16
16
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
17
17
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
18
18
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
@@ -1 +1 @@
1
- {"version":3,"file":"IAccount.d.ts","sourceRoot":"","sources":["../../../src/account/IAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;IACf,YAAY,IAAI,MAAM,CAAC;IACvB,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO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CACb,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChC,MAAM,CACJ,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,CAAC,EAAE,OAAO,OAChC;CACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"IAccount.js","sourceRoot":"","sources":["../../../src/account/IAccount.ts"],"names":[],"mappings":"","sourcesContent":["import { ITransactionDetails } from '..';\nimport { IAccountBalanceResponse } from './AccountBalance';\nimport { IAccountSignResponse } from './AccountSign';\nimport { Args } from '@massalabs/web3-utils';\n\n/**\n * This interface represents an Account object.\n *\n */\nexport interface IAccount {\n address(): string;\n name(): string;\n providerName(): string;\n balance(): Promise<IAccountBalanceResponse>;\n sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;\n buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;\n sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;\n sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails>;\n callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution?: boolean,\n );\n}\n"]}
1
+ {"version":3,"file":"IAccount.js","sourceRoot":"","sources":["../../../src/account/IAccount.ts"],"names":[],"mappings":"","sourcesContent":["import { ITransactionDetails } from '..';\nimport { IAccountBalanceResponse } from './AccountBalance';\nimport { IAccountSignOutput } from './AccountSign';\nimport { Args } from '@massalabs/web3-utils';\n\n/**\n * This interface represents an Account object.\n *\n */\nexport interface IAccount {\n address(): string;\n name(): string;\n providerName(): string;\n balance(): Promise<IAccountBalanceResponse>;\n sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;\n buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;\n sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;\n sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails>;\n callSC(\n contractAddress: string,\n functionName: string,\n parameter: Uint8Array | Args,\n amount: bigint,\n fee: bigint,\n maxGas: bigint,\n nonPersistentExecution?: boolean,\n );\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
3
3
  import { ITransactionDetails } from '..';
4
- import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse } from '../account';
4
+ import { IAccountBalanceResponse, IAccountDetails } from '../account';
5
5
  import { IAccount } from '../account/IAccount';
6
6
  import { NodeStatus } from './NodeStatus';
7
7
  import { JSON_RPC_REQUEST_METHOD } from './jsonRpcMethods';
8
+ import { IAccountSignOutput } from '../account/AccountSign';
8
9
  /**
9
10
  * The RPC we are using to query the node
10
11
  */
@@ -37,7 +38,7 @@ export declare class BearbyAccount implements IAccount {
37
38
  providerName(): string;
38
39
  connect(): Promise<void>;
39
40
  balance(): Promise<IAccountBalanceResponse>;
40
- sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;
41
+ sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;
41
42
  buyRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
42
43
  sellRolls(amount: bigint, fee: bigint): Promise<ITransactionDetails>;
43
44
  sendTransaction(amount: bigint, recipientAddress: string, fee: bigint): Promise<ITransactionDetails>;
@@ -1 +1 @@
1
- {"version":3,"file":"BearbyAccount.d.ts","sourceRoot":"","sources":["../../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBA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,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;IA6ChE;;;;;;;;;;;OAWG;IACU,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAKjD;;;;;;;;;OASG;cACa,kBAAkB,CAAC,CAAC,EAClC,QAAQ,EAAE,uBAAuB,EACjC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC;IAYb;;;;;;;;;;;;OAYG;YACW,oBAAoB;IAwCrB,mBAAmB,CAC9B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,8BAA8B,CAAC;CAmE3C"}
@@ -5,7 +5,6 @@ const bearby_js_1 = require("@hicaru/bearby.js");
5
5
  const RequestHandler_1 = require("../massaStation/RequestHandler");
6
6
  const jsonRpcMethods_1 = require("./jsonRpcMethods");
7
7
  const axios_1 = require("axios");
8
- const bs58check_1 = require("bs58check");
9
8
  /**
10
9
  * The maximum allowed gas for a read operation
11
10
  */
@@ -93,7 +92,7 @@ class BearbyAccount {
93
92
  const signature = await bearby_js_1.web3.wallet.signMessage(strData);
94
93
  return {
95
94
  publicKey: signature.publicKey,
96
- signature: (0, bs58check_1.decode)(signature.signature),
95
+ base58Encoded: signature.signature,
97
96
  };
98
97
  }
99
98
  // need testing
@@ -1 +1 @@
1
- {"version":3,"file":"BearbyAccount.js","sourceRoot":"","sources":["../../../src/bearbyWallet/BearbyAccount.ts"],"names":[],"mappings":";;;AAYA,iDAAoD;AACpD,mEAGwC;AAGxC,qDAA2D;AAC3D,iCAAkE;AAClE,yCAAmC;AACnC;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAa,CAAC,CAAC;AAEjD;;GAEG;AACU,QAAA,eAAe,GAAG,mCAAmC,CAAC;AAEnE,IAAY,cAMX;AAND,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,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;AAjWD,sCAiWC","sourcesContent":["import {\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 { CallParam, 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';\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<IAccountSignResponse> {\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 signature: decode(signature.signature),\n } as IAccountSignResponse;\n }\n\n // need testing\n public async buyRolls(\n amount: bigint,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n await this.connect();\n const signedTx = await web3.wallet.signTransaction({\n type: OperationsType.RollBuy,\n amount: amount.toString(),\n fee: fee.toString(),\n payload: '', // TODO: check how do we have to set it\n });\n\n return {\n operationId: signedTx,\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 signedTx = await web3.wallet.signTransaction({\n type: OperationsType.RollSell,\n amount: amount.toString(),\n fee: fee.toString(),\n payload: '', // TODO: check how do we have to set it\n });\n return {\n operationId: signedTx,\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 const signedTx = await web3.wallet.signTransaction({\n type: OperationsType.Payment,\n amount: amount.toString(),\n recipient: recipientAddress,\n fee: fee.toString(),\n payload: '',\n });\n\n return {\n operationId: signedTx,\n } as ITransactionDetails;\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 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 if (parameter instanceof Uint8Array) {\n throw new Error(\n 'Bearby wallet does not support Uint8Array as parameter. Please use Args instead',\n );\n }\n // setup the params from Args\n let params: CallParam[] = [];\n try {\n params = parameter.getArgsList().map((arg) => {\n return {\n type: arg.type,\n value: arg.value,\n } as CallParam;\n });\n } catch (ex) {\n throw new Error(`\n Bearby wallet does not support Uint8Array, serializable, and serializableObjectArray. \n To use them switch to MassaStation`);\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 parameters: params,\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":";;;AAYA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AA,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;AAjWD,sCAiWC","sourcesContent":["import {\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 { CallParam, 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';\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 signedTx = await web3.wallet.signTransaction({\n type: OperationsType.RollBuy,\n amount: amount.toString(),\n fee: fee.toString(),\n payload: '', // TODO: check how do we have to set it\n });\n\n return {\n operationId: signedTx,\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 signedTx = await web3.wallet.signTransaction({\n type: OperationsType.RollSell,\n amount: amount.toString(),\n fee: fee.toString(),\n payload: '', // TODO: check how do we have to set it\n });\n return {\n operationId: signedTx,\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 const signedTx = await web3.wallet.signTransaction({\n type: OperationsType.Payment,\n amount: amount.toString(),\n recipient: recipientAddress,\n fee: fee.toString(),\n payload: '',\n });\n\n return {\n operationId: signedTx,\n } as ITransactionDetails;\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 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 if (parameter instanceof Uint8Array) {\n throw new Error(\n 'Bearby wallet does not support Uint8Array as parameter. Please use Args instead',\n );\n }\n // setup the params from Args\n let params: CallParam[] = [];\n try {\n params = parameter.getArgsList().map((arg) => {\n return {\n type: arg.type,\n value: arg.value,\n } as CallParam;\n });\n } catch (ex) {\n throw new Error(`\n Bearby wallet does not support Uint8Array, serializable, and serializableObjectArray. \n To use them switch to MassaStation`);\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 parameters: params,\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,7 +1,8 @@
1
1
  /// <reference types="node" />
2
- import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse, ITransactionDetails } from '..';
2
+ import { IAccountBalanceResponse, IAccountDetails, ITransactionDetails } from '..';
3
3
  import { IAccount } from '../account/IAccount';
4
4
  import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
5
+ import { IAccountSignOutput } from '../account/AccountSign';
5
6
  /**
6
7
  * This module contains the MassaStationAccount class. It is responsible for representing an account in
7
8
  * the MassaStation wallet.
@@ -52,7 +53,7 @@ export declare class MassaStationAccount implements IAccount {
52
53
  * @param data - The message to be signed.
53
54
  * @returns An IAccountSignResponse object. It contains the signature of the message.
54
55
  */
55
- sign(data: Buffer | Uint8Array | string): Promise<IAccountSignResponse>;
56
+ sign(data: Buffer | Uint8Array | string): Promise<IAccountSignOutput>;
56
57
  /**
57
58
  * This method aims to buy rolls on behalf of the sender.
58
59
  *
@@ -1 +1 @@
1
- {"version":3,"file":"MassaStationAccount.d.ts","sourceRoot":"","sources":["../../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EACL,IAAI,EAEJ,8BAA8B,EAC/B,MAAM,uBAAuB,CAAC;AAoC/B;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;gBACgB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAA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,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;IAyCnD,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAoB7C,mBAAmB,CAC9B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,8BAA8B,CAAC;CAgE3C"}
@@ -4,6 +4,7 @@ exports.MassaStationAccount = void 0;
4
4
  const RequestHandler_1 = require("./RequestHandler");
5
5
  const MassaStationProvider_1 = require("./MassaStationProvider");
6
6
  const argsToBase64_1 = require("../utils/argsToBase64");
7
+ const bs58check_1 = require("bs58check");
7
8
  /**
8
9
  * The maximum allowed gas for a read operation
9
10
  */
@@ -97,11 +98,10 @@ class MassaStationAccount {
97
98
  if (signOpResponse.isError || signOpResponse.error) {
98
99
  throw signOpResponse.error;
99
100
  }
100
- // convert signOpResponse.result.signature to Uint8Array
101
- const signature = new Uint8Array(Buffer.from(signOpResponse.result.signature));
101
+ const signature = (0, bs58check_1.encode)(Buffer.from(signOpResponse.result.signature, 'base64'));
102
102
  return {
103
103
  publicKey: signOpResponse.result.publicKey,
104
- signature: signature,
104
+ base58Encoded: signature,
105
105
  };
106
106
  }
107
107
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"MassaStationAccount.js","sourceRoot":"","sources":["../../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":";;;AAOA,qDAAgF;AAChF,iEAGgC;AAOhC,wDAAyE;AAEzE;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAa,CAAC,CAAC;AA6BjD;;;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,CAAC;YACrE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;SAC3B,CAAC;IACJ,CAAC;CACF;AAvWD,kDAuWC","sourcesContent":["import {\n IAccountBalanceResponse,\n IAccountDetails,\n IAccountSignResponse,\n ITransactionDetails,\n} from '..';\nimport { IAccount } from '../account/IAccount';\nimport { JsonRpcResponseData, getRequest, postRequest } from './RequestHandler';\nimport {\n MASSA_STATION_URL,\n MASSA_STATION_ACCOUNTS_URL,\n} from './MassaStationProvider';\nimport {\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\n\nimport { argsToBase64, uint8ArrayToBase64 } from '../utils/argsToBase64';\n\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * This interface represents the payload returned by making a call to MassaStation's sign\n * operation `/signOperation` url.\n */\ninterface ISignOperation {\n operation: string;\n batch?: boolean;\n correlationId?: string;\n}\n\n/**\n * This interface represents the the individual wallet's final and pending balances returned by MassaStation\n */\ninterface IBalance {\n final: string;\n pending: string;\n}\n\n/**\n * This interface represents the payload returned by making a call to MassaStation's get balances url.\n */\ninterface IAddressesBalances {\n addressesAttributes: {\n [key: string]: { balance: IBalance };\n };\n}\n\n/**\n * This module contains the MassaStationAccount class. It is responsible for representing an account in\n * the MassaStation wallet.\n *\n * @remarks\n * This class provides methods to interact with MassaStation account's {@link balance} and to {@link sign} messages.\n *\n */\nexport class MassaStationAccount 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 let signOpResponse: JsonRpcResponseData<IAddressesBalances> = null;\n try {\n signOpResponse = await getRequest<IAddressesBalances>(\n `${MASSA_STATION_URL}massa/addresses?attributes=balance&addresses=${this._address}`,\n );\n } catch (ex) {\n console.error(`MassaStation account balance error`);\n throw ex;\n }\n if (signOpResponse.isError || signOpResponse.error) {\n throw signOpResponse.error;\n }\n const balance: IBalance =\n signOpResponse.result.addressesAttributes[this._address].balance;\n return {\n finalBalance: balance.final,\n candidateBalance: balance.pending,\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(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignResponse> {\n let signOpResponse: JsonRpcResponseData<IAccountSignResponse> = null;\n try {\n signOpResponse = await postRequest<IAccountSignResponse>(\n `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/sign`,\n {\n operation: Buffer.from(data).toString('base64'),\n batch: false,\n } as ISignOperation,\n );\n } catch (ex) {\n console.error(`MassaStation account signing error`);\n throw ex;\n }\n if (signOpResponse.isError || signOpResponse.error) {\n throw signOpResponse.error;\n }\n // convert signOpResponse.result.signature to Uint8Array\n const signature = new Uint8Array(\n Buffer.from(signOpResponse.result.signature),\n );\n return {\n publicKey: signOpResponse.result.publicKey,\n signature: signature,\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 bought.\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 let buyRollsOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n side: 'buy',\n };\n try {\n buyRollsOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(`MassaStation account: error while buying rolls: ${ex}`);\n throw ex;\n }\n if (buyRollsOpResponse.isError || buyRollsOpResponse.error) {\n throw buyRollsOpResponse.error;\n }\n return buyRollsOpResponse.result;\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 let sellRollsOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n side: 'sell',\n };\n try {\n sellRollsOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(`MassaStation account: error while selling rolls: ${ex}`);\n throw ex;\n }\n if (sellRollsOpResponse.isError || sellRollsOpResponse.error) {\n throw sellRollsOpResponse.error;\n }\n return sellRollsOpResponse.result;\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 async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n let sendTxOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/transfer`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n recipientAddress: recipientAddress,\n };\n try {\n sendTxOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(\n `MassaStation account: error while sending transaction: ${ex}`,\n );\n throw ex;\n }\n if (sendTxOpResponse.isError || sendTxOpResponse.error) {\n throw sendTxOpResponse.error;\n }\n return sendTxOpResponse.result;\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 if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n // convert parameter to base64\n let args = '';\n if (parameter instanceof Uint8Array) {\n args = uint8ArrayToBase64(parameter);\n } else {\n args = argsToBase64(parameter);\n }\n let CallSCOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_URL}cmd/executeFunction`;\n const body = {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: args,\n coins: Number(amount),\n };\n try {\n CallSCOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.log(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n throw ex;\n }\n if (CallSCOpResponse.isError || CallSCOpResponse.error) {\n throw CallSCOpResponse.error;\n }\n return CallSCOpResponse.result;\n }\n\n public async getNodeUrlFromMassaStation(): Promise<string> {\n // get the node url from MassaStation\n let nodesResponse: JsonRpcResponseData<unknown> = null;\n let node = '';\n try {\n nodesResponse = await getRequest<unknown>(\n `${MASSA_STATION_URL}massa/node`,\n );\n if (nodesResponse.isError || nodesResponse.error) {\n throw nodesResponse.error.message;\n }\n // transform nodesResponse.result to a json and then get the \"url\" property\n const nodes = nodesResponse.result as { url: string };\n node = nodes.url;\n } catch (ex) {\n throw new Error(`MassaStation nodes retrieval error: ${ex}`);\n }\n return node;\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 const node = await this.getNodeUrlFromMassaStation();\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 };\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":"MassaStationAccount.js","sourceRoot":"","sources":["../../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":";;;AAOA,qDAAgF;AAChF,iEAGgC;AAOhC,wDAAyE;AAEzE,yCAAmD;AAEnD;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,UAAa,CAAC,CAAC;AA6BjD;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAK9B;;;;;;;;;;;;OAYG;IACH,YAAmB,EAAE,OAAO,EAAE,IAAI,EAAmB,EAAE,YAAoB;QACzE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,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,IAAI,cAAc,GAA4C,IAAI,CAAC;QACnE,IAAI;YACF,cAAc,GAAG,MAAM,IAAA,2BAAU,EAC/B,GAAG,wCAAiB,gDAAgD,IAAI,CAAC,QAAQ,EAAE,CACpF,CAAC;SACH;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,oCAAoC,C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AC,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;AA1WD,kDA0WC","sourcesContent":["import {\n IAccountBalanceResponse,\n IAccountDetails,\n IAccountSignResponse,\n ITransactionDetails,\n} from '..';\nimport { IAccount } from '../account/IAccount';\nimport { JsonRpcResponseData, getRequest, postRequest } from './RequestHandler';\nimport {\n MASSA_STATION_URL,\n MASSA_STATION_ACCOUNTS_URL,\n} from './MassaStationProvider';\nimport {\n Args,\n IContractReadOperationData,\n IContractReadOperationResponse,\n} from '@massalabs/web3-utils';\n\nimport { argsToBase64, uint8ArrayToBase64 } from '../utils/argsToBase64';\nimport { IAccountSignOutput } from '../account/AccountSign';\nimport { encode as base58Encode } from 'bs58check';\n\n/**\n * The maximum allowed gas for a read operation\n */\nconst MAX_READ_BLOCK_GAS = BigInt(4_294_967_295);\n\n/**\n * This interface represents the payload returned by making a call to MassaStation's sign\n * operation `/signOperation` url.\n */\ninterface ISignOperation {\n operation: string;\n batch?: boolean;\n correlationId?: string;\n}\n\n/**\n * This interface represents the the individual wallet's final and pending balances returned by MassaStation\n */\ninterface IBalance {\n final: string;\n pending: string;\n}\n\n/**\n * This interface represents the payload returned by making a call to MassaStation's get balances url.\n */\ninterface IAddressesBalances {\n addressesAttributes: {\n [key: string]: { balance: IBalance };\n };\n}\n\n/**\n * This module contains the MassaStationAccount class. It is responsible for representing an account in\n * the MassaStation wallet.\n *\n * @remarks\n * This class provides methods to interact with MassaStation account's {@link balance} and to {@link sign} messages.\n *\n */\nexport class MassaStationAccount 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 let signOpResponse: JsonRpcResponseData<IAddressesBalances> = null;\n try {\n signOpResponse = await getRequest<IAddressesBalances>(\n `${MASSA_STATION_URL}massa/addresses?attributes=balance&addresses=${this._address}`,\n );\n } catch (ex) {\n console.error(`MassaStation account balance error`);\n throw ex;\n }\n if (signOpResponse.isError || signOpResponse.error) {\n throw signOpResponse.error;\n }\n const balance: IBalance =\n signOpResponse.result.addressesAttributes[this._address].balance;\n return {\n finalBalance: balance.final,\n candidateBalance: balance.pending,\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(\n data: Buffer | Uint8Array | string,\n ): Promise<IAccountSignOutput> {\n let signOpResponse: JsonRpcResponseData<IAccountSignResponse> = null;\n\n try {\n signOpResponse = await postRequest<IAccountSignResponse>(\n `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/sign`,\n {\n operation: Buffer.from(data).toString('base64'),\n batch: false,\n } as ISignOperation,\n );\n } catch (ex) {\n console.error(`MassaStation account signing error`);\n throw ex;\n }\n\n if (signOpResponse.isError || signOpResponse.error) {\n throw signOpResponse.error;\n }\n\n const signature = base58Encode(\n Buffer.from(signOpResponse.result.signature, 'base64'),\n );\n\n return {\n publicKey: signOpResponse.result.publicKey,\n base58Encoded: signature,\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 bought.\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 let buyRollsOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n side: 'buy',\n };\n try {\n buyRollsOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(`MassaStation account: error while buying rolls: ${ex}`);\n throw ex;\n }\n if (buyRollsOpResponse.isError || buyRollsOpResponse.error) {\n throw buyRollsOpResponse.error;\n }\n return buyRollsOpResponse.result;\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 let sellRollsOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/rolls`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n side: 'sell',\n };\n try {\n sellRollsOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(`MassaStation account: error while selling rolls: ${ex}`);\n throw ex;\n }\n if (sellRollsOpResponse.isError || sellRollsOpResponse.error) {\n throw sellRollsOpResponse.error;\n }\n return sellRollsOpResponse.result;\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 async sendTransaction(\n amount: bigint,\n recipientAddress: string,\n fee: bigint,\n ): Promise<ITransactionDetails> {\n let sendTxOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_ACCOUNTS_URL}/${this._name}/transfer`;\n const body = {\n fee: fee.toString(),\n amount: amount.toString(),\n recipientAddress: recipientAddress,\n };\n try {\n sendTxOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.error(\n `MassaStation account: error while sending transaction: ${ex}`,\n );\n throw ex;\n }\n if (sendTxOpResponse.isError || sendTxOpResponse.error) {\n throw sendTxOpResponse.error;\n }\n return sendTxOpResponse.result;\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 if (nonPersistentExecution) {\n return this.nonPersistentCallSC(\n contractAddress,\n functionName,\n parameter,\n amount,\n fee,\n maxGas,\n );\n }\n // convert parameter to base64\n let args = '';\n if (parameter instanceof Uint8Array) {\n args = uint8ArrayToBase64(parameter);\n } else {\n args = argsToBase64(parameter);\n }\n let CallSCOpResponse: JsonRpcResponseData<ITransactionDetails> = null;\n const url = `${MASSA_STATION_URL}cmd/executeFunction`;\n const body = {\n nickname: this._name,\n name: functionName,\n at: contractAddress,\n args: args,\n coins: Number(amount),\n };\n try {\n CallSCOpResponse = await postRequest<ITransactionDetails>(url, body);\n } catch (ex) {\n console.log(\n `MassaStation account: error while interacting with smart contract: ${ex}`,\n );\n throw ex;\n }\n if (CallSCOpResponse.isError || CallSCOpResponse.error) {\n throw CallSCOpResponse.error;\n }\n return CallSCOpResponse.result;\n }\n\n public async getNodeUrlFromMassaStation(): Promise<string> {\n // get the node url from MassaStation\n let nodesResponse: JsonRpcResponseData<unknown> = null;\n let node = '';\n try {\n nodesResponse = await getRequest<unknown>(\n `${MASSA_STATION_URL}massa/node`,\n );\n if (nodesResponse.isError || nodesResponse.error) {\n throw nodesResponse.error.message;\n }\n // transform nodesResponse.result to a json and then get the \"url\" property\n const nodes = nodesResponse.result as { url: string };\n node = nodes.url;\n } catch (ex) {\n throw new Error(`MassaStation nodes retrieval error: ${ex}`);\n }\n return node;\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 const node = await this.getNodeUrlFromMassaStation();\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 };\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,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { IAccountBalanceResponse } from './AccountBalance';
3
- import { IAccountSignResponse } from './AccountSign';
3
+ import { IAccountSignOutput } from './AccountSign';
4
4
  import { IAccountDetails } from './IAccountDetails';
5
5
  import { ITransactionDetails } from '..';
6
6
  import { IAccount } from './IAccount';
@@ -54,7 +54,7 @@ export declare class Account implements IAccount {
54
54
  * @param data - The message to be signed.
55
55
  * @returns An IAccountSignResponse object. It contains the signature of the message.
56
56
  */
57
- sign(data: Buffer | Uint8Array): Promise<IAccountSignResponse>;
57
+ sign(data: Buffer | Uint8Array): Promise<IAccountSignOutput>;
58
58
  /**
59
59
  * This method aims to buy rolls on behalf of the sender.
60
60
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../../src/account/Account.ts"],"names":[],"mappings":";AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAqB,mBAAmB,EAAE,MAAM,IAAI,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAItC,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE7E;;;;;;GAMG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IACtC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;gBACgB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAM3E;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAcxD;;;;;OAKG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAc3E;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAiB/B;;;;;;OAMG;IACU,SAAS,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAiB/B;;;;;;OAMG;IACU,eAAe,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