Skip to content

Commit

Permalink
Merge branch 'develop' into feat/starknet-v0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvkelawala authored Sep 6, 2022
2 parents f0c30bd + d81f24d commit 88e680f
Show file tree
Hide file tree
Showing 9 changed files with 4,837 additions and 6,620 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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [4.4.1](https://github.com/0xs34n/starknet.js/compare/v4.4.0...v4.4.1) (2022-09-01)

### Bug Fixes

- supply calldata as hexadecimal string array ([44cb4c5](https://github.com/0xs34n/starknet.js/commit/44cb4c5f108a2ea8fcd77147f053e068189d4f33))

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

### Bug Fixes

- delete premature session account file ([ca3e70b](https://github.com/0xs34n/starknet.js/commit/ca3e70b06d21dba8b2074512251cf232ed8be46b))
- session ([00269bf](https://github.com/0xs34n/starknet.js/commit/00269bfd23ed647270a1efd699af7c36978965c7))
- session account prooving ([0b56833](https://github.com/0xs34n/starknet.js/commit/0b56833f6eb7557d55725a505a01185bbc9756db))
- tests ([4586e93](https://github.com/0xs34n/starknet.js/commit/4586e93f10a2a43c375a23d851a9778bab412fcc))
- typo ([1c60a4d](https://github.com/0xs34n/starknet.js/commit/1c60a4d4b306879422769a6c2afc4fd6c39c4c07))

### Features

- add merkle trees ([e9b8674](https://github.com/0xs34n/starknet.js/commit/e9b8674f51c6d6fe57772a4c88b162c5132cfbdd))
- add visibility modifiers ([cd1a23d](https://github.com/0xs34n/starknet.js/commit/cd1a23d74b49407c27314a12d5bc149ed40209f3))
- allow merkle trees as native type in eip712 like messages ([65b7766](https://github.com/0xs34n/starknet.js/commit/65b7766c29eca4f4d0e89f6ad1368fedd5e0e18e))
- session ([9ac48cc](https://github.com/0xs34n/starknet.js/commit/9ac48cc15c1c7b0e504adfc79a7f382f5d0b55d0))
- session needs to be aware of the whole tree ([11e10bd](https://github.com/0xs34n/starknet.js/commit/11e10bda0f020a670854d941a54142d55936fc18))

## [4.3.1](https://github.com/0xs34n/starknet.js/compare/v4.3.0...v4.3.1) (2022-08-31)

### Bug Fixes
Expand Down
31 changes: 29 additions & 2 deletions __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
import { RpcProvider } from '../src';
import { describeIfRpc, getTestProvider } from './fixtures';
import { Account, RpcProvider, ec } from '../src';
import {
compiledOpenZeppelinAccount,
describeIfRpc,
getTestAccount,
getTestProvider,
} from './fixtures';

describeIfRpc('RPCProvider', () => {
let rpcProvider: RpcProvider;
let accountPublicKey: string;

beforeAll(async () => {
rpcProvider = getTestProvider() as RpcProvider;
const account = getTestAccount(rpcProvider);

expect(account).toBeInstanceOf(Account);

const accountKeyPair = ec.genKeyPair();
accountPublicKey = ec.getStarkKey(accountKeyPair);
});

describe('RPC methods', () => {
test('getChainId', async () => {
const chainId = await rpcProvider.getChainId();
expect(chainId).toBe('0x534e5f474f45524c49');
});

test('deployContract', async () => {
const { contract_address, transaction_hash } = await rpcProvider.deployContract({
contract: compiledOpenZeppelinAccount,
constructorCalldata: [accountPublicKey],
addressSalt: accountPublicKey,
});
await rpcProvider.waitForTransaction(transaction_hash);
expect(contract_address).toBeTruthy();
expect(transaction_hash).toBeTruthy();
});

test.todo('getEstimateFee');

test.todo('invokeFunction');
});
});
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "starknet",
"version": "4.3.1",
"version": "4.4.1",
"description": "JavaScript library for StarkNet",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
13 changes: 9 additions & 4 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import { RPC } from '../types/api';
import fetch from '../utils/fetchPonyfill';
import { getSelectorFromName } from '../utils/hash';
import { stringify } from '../utils/json';
import { BigNumberish, bigNumberishArrayToDecimalStringArray, toBN, toHex } from '../utils/number';
import {
BigNumberish,
bigNumberishArrayToHexadecimalStringArray,
toBN,
toHex,
} from '../utils/number';
import { parseCalldata, parseContract, wait } from '../utils/provider';
import { RPCResponseParser } from '../utils/responseParser/rpc';
import { randomAddress } from '../utils/stark';
Expand Down Expand Up @@ -165,7 +170,7 @@ export class RpcProvider implements ProviderInterface {
{
contract_address: invocation.contractAddress,
calldata: parseCalldata(invocation.calldata),
signature: bigNumberishArrayToDecimalStringArray(invocation.signature || []),
signature: bigNumberishArrayToHexadecimalStringArray(invocation.signature || []),
version: toHex(toBN(invocationDetails?.version || 0)),
},
blockIdentifier,
Expand Down Expand Up @@ -196,7 +201,7 @@ export class RpcProvider implements ProviderInterface {

return this.fetchEndpoint('starknet_addDeployTransaction', [
addressSalt ?? randomAddress(),
bigNumberishArrayToDecimalStringArray(constructorCalldata ?? []),
bigNumberishArrayToHexadecimalStringArray(constructorCalldata ?? []),
{
program: contractDefinition.program,
entry_points_by_type: contractDefinition.entry_points_by_type,
Expand All @@ -213,7 +218,7 @@ export class RpcProvider implements ProviderInterface {
contract_address: functionInvocation.contractAddress,
calldata: parseCalldata(functionInvocation.calldata),
},
bigNumberishArrayToDecimalStringArray(functionInvocation.signature || []),
bigNumberishArrayToHexadecimalStringArray(functionInvocation.signature || []),
toHex(toBN(details.maxFee || 0)),
toHex(toBN(details.version || 0)),
]).then(this.responseParser.parseInvokeFunctionResponse);
Expand Down
4 changes: 4 additions & 0 deletions src/utils/number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ export function assertInRange(
export function bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[] {
return rawCalldata.map((x) => toBN(x).toString(10));
}

export function bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[] {
return rawCalldata.map((x) => toHex(toBN(x)));
}
6 changes: 6 additions & 0 deletions www/docs/API/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ const signature = await this.signer.signTransaction(transactions, signerDetails)
}
```

### bigNumberishArrayToHexadecimalStringArray

`bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[]`

Convert BigNumberish array to hexadecimal string array. Used for signature conversion.

<hr />

## **uint256**
Expand Down
Loading

0 comments on commit 88e680f

Please sign in to comment.