Skip to content

Commit

Permalink
Merge branch 'develop' into test/default-nodes-rpc-version
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Apr 3, 2024
2 parents 4ec6e7a + a85d48e commit a08f872
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 64 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [6.7.0](https://github.com/starknet-io/starknet.js/compare/v6.6.6...v6.7.0) (2024-04-03)

### Features

- readme & trigger release ([5341c42](https://github.com/starknet-io/starknet.js/commit/5341c42da8bf5d2f82e4446a60b5e4fdc9c4e2fe))

## [6.6.6](https://github.com/starknet-io/starknet.js/compare/v6.6.5...v6.6.6) (2024-03-25)

### Bug Fixes
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ Install starknet with `npm`
# latest official release (main branch)
$ npm install starknet

# or for latest pre-release version (develop branch):
# or for latest pre-release version (develop branch)
$ npm install starknet@next

# or for latest beta release version (beta branch)
$ npm install starknet@beta
```

Import `starknet` and use the [API](https://www.starknetjs.com/docs/API/).
Expand Down
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starknet",
"version": "6.6.6",
"version": "6.7.0",
"description": "JavaScript library for Starknet",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -99,6 +99,7 @@
"isomorphic-fetch": "^3.0.0",
"lossless-json": "^4.0.1",
"pako": "^2.0.4",
"starknet-types": "^0.0.4",
"ts-mixer": "^6.0.3",
"url-join": "^4.0.1"
},
Expand Down
2 changes: 2 additions & 0 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ export class Account extends Provider implements AccountInterface {
unit: 'FRI',
suggestedMaxFee: ZERO,
resourceBounds: estimateFeeToBounds(ZERO),
data_gas_consumed: 0n,
data_gas_price: 0n,
};
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export * from './utils/calldata/enum';
export * from './utils/contract';
export * from './utils/events';
export * from './utils/transactionReceipt';
export * as wallet from './wallet/connect';

/**
* Deprecated
Expand Down
2 changes: 2 additions & 0 deletions src/types/provider/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export interface EstimateFeeResponse {
unit: PRICE_UNIT;
suggestedMaxFee: bigint;
resourceBounds: ResourceBounds;
data_gas_consumed: bigint;
data_gas_price: bigint;
}

export type EstimateFeeResponseBulk = Array<EstimateFeeResponse>;
Expand Down
59 changes: 9 additions & 50 deletions src/types/typedData.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,9 @@
export enum TypedDataRevision {
Active = '1',
Legacy = '0',
}

export type StarknetEnumType = {
name: string;
type: 'enum';
contains: string;
};

export type StarknetMerkleType = {
name: string;
type: 'merkletree';
contains: string;
};

/**
* A single type, as part of a struct. The `type` field can be any of the EIP-712 supported types.
*
* Note that the `uint` and `int` aliases like in Solidity, and fixed point numbers are not supported by the EIP-712
* standard.
*/
export type StarknetType =
| {
name: string;
type: string;
}
| StarknetEnumType
| StarknetMerkleType;

/**
* The EIP712 domain struct. Any of these fields are optional, but it must contain at least one field.
*/
export interface StarknetDomain extends Record<string, unknown> {
name?: string;
version?: string;
chainId?: string | number;
revision?: string;
}

/**
* The complete typed data, with all the structs, domain data, primary type of the message, and the message itself.
*/
export interface TypedData {
types: Record<string, StarknetType[]>;
primaryType: string;
domain: StarknetDomain;
message: Record<string, unknown>;
}
// Reexport types from package
export {
TypedDataRevision,
type StarknetEnumType,
type StarknetMerkleType,
type StarknetType,
type StarknetDomain,
type TypedData,
} from 'starknet-types';
14 changes: 9 additions & 5 deletions src/utils/responseParser/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import {
BlockWithTxHashes,
ContractClassPayload,
ContractClassResponse,
TransactionReceipt,
EstimateFeeResponse,
EstimateFeeResponseBulk,
GetBlockResponse,
FeeEstimate,
GetBlockResponse,
GetTxReceiptResponseWithoutHelper,
RpcProviderOptions,
SimulateTransactionResponse,
SimulatedTransaction,
RpcProviderOptions,
GetTxReceiptResponseWithoutHelper,
TransactionReceipt,
} from '../../types/provider';
import { toBigInt } from '../num';
import { isString } from '../shortString';
import { estimateFeeToBounds, estimatedFeeToMaxFee } from '../stark';
import { ResponseParser } from '.';
import { isString } from '../shortString';

export class RPCResponseParser
implements
Expand Down Expand Up @@ -80,6 +80,8 @@ export class RPCResponseParser
unit: val.unit,
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
resourceBounds: this.estimateFeeToBounds(val),
data_gas_consumed: val.data_gas_consumed ? toBigInt(val.data_gas_consumed) : 0n,
data_gas_price: val.data_gas_price ? toBigInt(val.data_gas_price) : 0n,
};
}

Expand All @@ -91,6 +93,8 @@ export class RPCResponseParser
unit: val.unit,
suggestedMaxFee: this.estimatedFeeToMaxFee(val.overall_fee),
resourceBounds: this.estimateFeeToBounds(val),
data_gas_consumed: val.data_gas_consumed ? toBigInt(val.data_gas_consumed) : 0n,
data_gas_price: val.data_gas_price ? toBigInt(val.data_gas_price) : 0n,
}));
}

Expand Down
5 changes: 3 additions & 2 deletions src/wallet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
type AddStarknetChainParameters,
type NetworkChangeEventHandler,
type WatchAssetParameters,
} from 'get-starknet-core';
} from 'starknet-types';

import { Account, AccountInterface } from '../account';
import { StarknetChainId } from '../constants';
import { ProviderInterface } from '../provider';
import {
AllowArray,
Expand Down Expand Up @@ -37,6 +37,7 @@ import {
watchAsset,
} from './connect';
import { StarknetWalletProvider } from './types';
import { StarknetChainId } from '../constants';

// Represent 'Selected Active' Account inside Connected Wallet
export class WalletAccount extends Account implements AccountInterface {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
type StarknetChainId,
type StarknetWindowObject,
type TypedData,
} from 'get-starknet-core';
} from 'starknet-types';

/**
* Request Permission for wallet account, return addresses that are allowed by user
Expand Down
1 change: 0 additions & 1 deletion src/wallet/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './account';
export * from './connect';
2 changes: 1 addition & 1 deletion src/wallet/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RpcMessage, type StarknetWindowObject } from 'get-starknet-core';
import { type RpcMessage, type StarknetWindowObject } from 'starknet-types';

// ---- TT Request Handler
export type RpcCall = Omit<RpcMessage, 'result'>;
Expand Down

0 comments on commit a08f872

Please sign in to comment.