Skip to content

Commit

Permalink
Merge branch 'develop' into feat/improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Sep 12, 2022
2 parents 7393d68 + b478579 commit 6ebe32b
Show file tree
Hide file tree
Showing 10 changed files with 4,808 additions and 6,616 deletions.
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Motivation and Resolution

...

### RPC version (if applicable)

...

## Usage related changes
Expand All @@ -19,6 +21,7 @@
- ...

## Checklist:

- [ ] Performed a self-review of the code
- [ ] Rebased to the last commit of the target branch (or merged it into my branch)
- [ ] Linked the issues which this PR resolves
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# [4.5.0](https://github.com/0xs34n/starknet.js/compare/v4.4.2...v4.5.0) (2022-09-09)

### Bug Fixes

- prevent undefined rpc chainId in account ([9f69229](https://github.com/0xs34n/starknet.js/commit/9f69229fcb5205bb3fd1fcc7eb7c627faa300561))
- repair chain fix ([d7758a6](https://github.com/0xs34n/starknet.js/commit/d7758a6d180cd1af89f8aefb37bce077b92c5fd5))

### Features

- optional abi field for deploy and declare rpc transactions ([ce62648](https://github.com/0xs34n/starknet.js/commit/ce626481cb6bc3dea77963482820ae6f50c82566))

## [4.4.2](https://github.com/0xs34n/starknet.js/compare/v4.4.1...v4.4.2) (2022-09-07)

### Bug Fixes

- dont import fetch from crosshatch ([a3ef41c](https://github.com/0xs34n/starknet.js/commit/a3ef41cac0e818f7429e6dd7654722ede1dc3796))
- use custom fetch ponyfill ([78f904a](https://github.com/0xs34n/starknet.js/commit/78f904a1d5aeb5efaba7fbdd853802529c80594b))
- use isomorphic-unfetch ([c63b6a1](https://github.com/0xs34n/starknet.js/commit/c63b6a138616936cf7a70f9098af5df290983c74))

## [4.4.1](https://github.com/0xs34n/starknet.js/compare/v4.4.0...v4.4.1) (2022-09-01)

### Bug Fixes
Expand Down
32 changes: 30 additions & 2 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starknet",
"version": "4.4.1",
"version": "4.5.0",
"description": "JavaScript library for StarkNet",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -85,6 +85,9 @@
],
"setupFilesAfterEnv": [
"./__tests__/jest.setup.ts"
],
"sandboxInjectedGlobals": [
"Math"
]
},
"importSort": {
Expand Down
6 changes: 4 additions & 2 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ export class Account extends Provider implements AccountInterface {
const transactions = Array.isArray(calls) ? calls : [calls];
const nonce = providedNonce ?? (await this.getNonce());
const version = toBN(feeTransactionVersion);
const chainId = await this.getChainId();

const signerDetails: InvocationsSignerDetails = {
walletAddress: this.address,
nonce: toBN(nonce),
maxFee: ZERO,
version,
chainId: this.chainId,
chainId,
};

const signature = await this.signer.signTransaction(transactions, signerDetails);
Expand Down Expand Up @@ -99,13 +100,14 @@ export class Account extends Provider implements AccountInterface {
}

const version = toBN(transactionVersion);
const chainId = await this.getChainId();

const signerDetails: InvocationsSignerDetails = {
walletAddress: this.address,
nonce,
maxFee,
version,
chainId: this.chainId,
chainId,
};

const signature = await this.signer.signTransaction(transactions, signerDetails, abis);
Expand Down
4 changes: 4 additions & 0 deletions src/provider/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export class Provider implements ProviderInterface {
return this.provider.chainId;
}

public async getChainId(): Promise<StarknetChainId> {
return this.provider.getChainId();
}

public async getBlock(blockIdentifier: BlockIdentifier = 'pending'): Promise<GetBlockResponse> {
return this.provider.getBlock(blockIdentifier);
}
Expand Down
7 changes: 7 additions & 0 deletions src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import { BlockIdentifier } from './utils';
export abstract class ProviderInterface {
public abstract chainId: StarknetChainId;

/**
* Gets the Starknet chain Id
*
* @returns the chain Id
*/
public abstract getChainId(): Promise<StarknetChainId>;

/**
* Calls a function on the StarkNet contract.
*
Expand Down
2 changes: 2 additions & 0 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class RpcProvider implements ProviderInterface {
{
program: contractDefinition.program,
entry_points_by_type: contractDefinition.entry_points_by_type,
abi: contractDefinition.abi, // rpc 2.0
},
toHex(toBN(version || 0)),
]).then(this.responseParser.parseDeclareContractResponse);
Expand All @@ -196,6 +197,7 @@ export class RpcProvider implements ProviderInterface {
{
program: contractDefinition.program,
entry_points_by_type: contractDefinition.entry_points_by_type,
abi: contractDefinition.abi, // rpc 2.0
},
]).then(this.responseParser.parseDeployContractResponse);
}
Expand Down
4 changes: 4 additions & 0 deletions src/provider/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ export class SequencerProvider implements ProviderInterface {
}
}

public async getChainId(): Promise<StarknetChainId> {
return Promise.resolve(this.chainId);
}

public async callContract(
{ contractAddress, entrypoint: entryPointSelector, calldata = [] }: Call,
blockIdentifier: BlockIdentifier = 'pending'
Expand Down
Loading

0 comments on commit 6ebe32b

Please sign in to comment.