Skip to content

Commit

Permalink
Update buildnet cherry pic (#426)
Browse files Browse the repository at this point in the history
* Introduce wallet provider (#423)

* Use wallet provider in massa-web3

* Remove constraint private provider

* Remove test on constraint private API and fix parameters format in call sc using wallet providers.

* Remove duplicate readsmart contract

* Rework client initialization

* Update package json (#425)

* Remove args and use web3-utils

* Update version

* update p json

---------

Co-authored-by: AurelienFT <[email protected]>

* update version minor

---------

Co-authored-by: AurelienFT <[email protected]>
Co-authored-by: AurelienFT <[email protected]>
  • Loading branch information
3 people authored Jul 27, 2023
1 parent 7cc1c96 commit 6adda18
Show file tree
Hide file tree
Showing 29 changed files with 3,499 additions and 4,400 deletions.
5,324 changes: 2,800 additions & 2,524 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@massalabs/massa-web3",
"version": "1.21.0",
"version": "1.22.0",
"description": "massa's web3 sdk client",
"main": "dist/cmd/index.js",
"module": "dist/esm/index.js",
Expand Down Expand Up @@ -58,6 +58,7 @@
"bundle.min.js"
],
"dependencies": {
"@massalabs/wallet-provider": "^1.2.0",
"@noble/ed25519": "^1.7.3",
"@noble/hashes": "^1.2.0",
"@types/ws": "^8.5.4",
Expand All @@ -79,6 +80,7 @@
"devDependencies": {
"@massalabs/eslint-config": "^0.0.9",
"@massalabs/prettier-config-as": "^0.0.2",
"@massalabs/web3-utils": "^1.1.0",
"@types/bn.js": "^5.1.1",
"@types/jest": "^29.5.2",
"@types/node": "^18.13.0",
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export { ISignedMessage } from './interfaces/ISignedMessage';
export { IStakingAddresses } from './interfaces/IStakingAddresses';
export { ITransactionData } from './interfaces/ITransactionData';
export { IBalance } from './interfaces/IBalance';
export { ISerializable } from './interfaces/ISerializable';
export { IDeserializedResult } from './interfaces/ISerializable';
export { IDatastoreEntry } from './interfaces/IDatastoreEntry';
export { IContractReadOperationData } from './interfaces/IContractReadOperationData';
export { IContractReadOperationResponse } from './interfaces/IContractReadOperationResponse';
Expand Down Expand Up @@ -89,9 +87,8 @@ export {
MASSA_PROTOFILE_KEY,
PROTO_FILE_SEPARATOR,
} from './web3/SmartContractsClient';
export * from './utils/arguments';
export * from '@massalabs/web3-utils';
export { fromMAS, toMAS, MassaUnits } from './utils/converters';
export * from './utils/serializers';

/** Exposed utils */
export * as utils from './utils/Xbqcrypto';
Expand Down
2 changes: 0 additions & 2 deletions src/interfaces/IAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* @see address - A string representing the address of the account.
* @see publicKey - A string representing the base58 encoded public key associated with the account.
* @see secretKey - A string representing the base58 encoded private key associated with the account.
* @see createdInThread - A number (optional) indicating the thread in which the account was created.
*/
export interface IAccount {
address: string | null;
publicKey: string | null;
secretKey: string | null;
createdInThread?: number;
}
74 changes: 74 additions & 0 deletions src/interfaces/IBaseAccount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { ICallData } from './ICallData';
import { IContractData } from './IContractData';
import { IRollsData } from './IRollsData';
import { ISignature } from './ISignature';
import { ITransactionData } from './ITransactionData';

/**
* Represents a BaseAccount object.
*
* @see sign - Sign an array of bytes.
* @see address - The address of the account.
* @see sellRolls - Sell rolls.
* @see buyRolls - Buy rolls.
* @see sendTransaction - Send a transaction.
* @see callSmartContract - Call a smart contract.
* @see deploySmartContract - Deploy a smart contract.
*/
export interface IBaseAccount {
/**
* Sign a message.
*
* @returns Signature of the message.
*/
sign(data: Buffer): Promise<ISignature>;

/**
* Verify integrity of the account.
*
* @throws - If the account is not valid.
*/
verify(): Promise<void>;

/**
* The address of the account.
*
* @returns The address of the account.
*/
address(): string;

/**
* @param txData - The transaction data.
*
* @returns A promise that resolves to an array of operation ids as strings.
*/
sellRolls(txData: IRollsData): Promise<string>;

/**
* @param txData - The transaction data.
*
* @returns A promise that resolves to an array of operation ids as strings.
*/
buyRolls(txData: IRollsData): Promise<string>;

/**
* @param txData - The transaction data.
*
* @returns A promise that resolves to an array of operation ids as strings.
*/
sendTransaction(txData: ITransactionData): Promise<string>;

/**
* @param callData - The call data.
*
* @returns A promise that resolves to the result of the call.
*/
callSmartContract(callData: ICallData): Promise<string>;

/**
* @param contractData - The contract data.
*
* @returns A promise that resolves to the address of the deployed contract.
*/
deploySmartContract(contractData: IContractData): Promise<string>;
}
3 changes: 2 additions & 1 deletion src/interfaces/IPublicApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ISlot } from './ISlot';
import { IGetGraphInterval } from './IGetGraphInterval';
import { IBlockcliqueBlockBySlot } from './IBlockcliqueBlockBySlot';
import { IGraphInterval } from './IGraphInterval';
import { BaseClient } from '../web3/BaseClient';

/**
* Represents a PublicApiClient object.
Expand All @@ -26,7 +27,7 @@ import { IGraphInterval } from './IGraphInterval';
* @see getBlockcliqueBlockBySlot - Get blockclique block by slot.
* @see getGraphInterval - Get graph interval.
*/
export interface IPublicApiClient {
export interface IPublicApiClient extends BaseClient {
/**
* Get the node status.
*
Expand Down
21 changes: 0 additions & 21 deletions src/interfaces/ISerializable.ts

This file was deleted.

9 changes: 6 additions & 3 deletions src/interfaces/ISmartContractsClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EOperationStatus } from './EOperationStatus';
import { IAccount } from './IAccount';
import { IBalance } from './IBalance';
import { IBaseAccount } from './IBaseAccount';
import { ICallData } from './ICallData';
import { IContractData } from './IContractData';
import { IContractReadOperationResponse } from './IContractReadOperationResponse';
Expand Down Expand Up @@ -32,7 +32,7 @@ export interface ISmartContractsClient {
*/
deploySmartContract(
contractData: IContractData,
executor?: IAccount,
executor?: IBaseAccount,
): Promise<string>;

/**
Expand All @@ -43,7 +43,10 @@ export interface ISmartContractsClient {
*
* @returns The operation id
*/
callSmartContract(callData: ICallData, executor?: IAccount): Promise<string>;
callSmartContract(
callData: ICallData,
executor?: IBaseAccount,
): Promise<string>;

/**
* Read a smart contract.
Expand Down
14 changes: 8 additions & 6 deletions src/interfaces/IWalletClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { IBalance } from './IBalance';
import { IRollsData } from './IRollsData';
import { ISignature } from './ISignature';
import { ITransactionData } from './ITransactionData';
import { BaseClient } from '../web3/BaseClient';
import { IBaseAccount } from './IBaseAccount';

/**
* Interface for WalletClient objects
Expand All @@ -23,20 +25,20 @@ import { ITransactionData } from './ITransactionData';
* @see buyRolls - buy rolls
* @see sellRolls - sell rolls
*/
export interface IWalletClient {
export interface IWalletClient extends BaseClient {
/**
* Set the base account.
*
* @param baseAccount - The base account as an IAccount object.
*/
setBaseAccount(baseAccount: IAccount): void;
setBaseAccount(baseAccount: IBaseAccount): void;

/**
* Get the base account.
*
* @returns The base account (or null if the base account is not set).
*/
getBaseAccount(): IAccount | null;
getBaseAccount(): IBaseAccount | null;

/**
* Get all accounts in the wallet.
Expand Down Expand Up @@ -139,7 +141,7 @@ export interface IWalletClient {
*/
sendTransaction(
txData: ITransactionData,
executor?: IAccount,
executor?: IBaseAccount,
): Promise<Array<string>>;

/**
Expand All @@ -150,7 +152,7 @@ export interface IWalletClient {
*
* @returns A promise that resolves to an array of operation ids as strings.
*/
buyRolls(txData: IRollsData, executor?: IAccount): Promise<Array<string>>;
buyRolls(txData: IRollsData, executor?: IBaseAccount): Promise<Array<string>>;

/**
* Sell rolls.
Expand All @@ -160,5 +162,5 @@ export interface IWalletClient {
*
* @returns A promise that resolves to an array of operation ids as strings.
*/
sellRolls(txData: IRollsData, executor: IAccount): Promise<Array<string>>;
sellRolls(txData: IRollsData, executor: IBaseAccount): Promise<Array<string>>;
}
Loading

0 comments on commit 6adda18

Please sign in to comment.