Skip to content

Commit

Permalink
Merge branch 'develop' into rpc-010-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Aug 29, 2022
2 parents 0c75f6f + 927e03d commit 72f3d4b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 39 deletions.
6 changes: 3 additions & 3 deletions www/docs/API/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This API is the primary way to interact with an account contract on StarkNet.

## Creating an instance

For creating new instance of Account, account contract must be deployed. Also there needs to be a Provider instance that will be passed in the constructor and key pair for the account.
To create a new instance of the Account, first an account contract must be deployed. Also there needs to be a Provider instance that will be passed in the constructor and key pair for the account.

`new starknet.Account(Provider, address, starkKeyPair)`

Expand All @@ -26,7 +26,7 @@ The address of the account contract.

account.**getNonce()** => _Promise < string >_

Gets new Nonce for the next transaction.
Gets the new Nonce for the next transaction.

<hr />

Expand All @@ -53,7 +53,7 @@ The _options_ object may include any of:

account.**execute**(calls [ , abi , transactionsDetail ]) => _Promise < AddTransactionResponse >_

Executes one or multiple calls using the account contract
Executes one or multiple calls using the account contract.

The _transactionsDetail_ object may include any of:

Expand Down
4 changes: 2 additions & 2 deletions www/docs/API/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < Result >_

The type of the result depends on the ABI. Result object will be returned with each parameter available positionally and if the parameter is named, it will also be available by its name.

The _overrides_ object for a read-only method may include any of:
The _overrides_ object for a read-only method may include:

- overrides.**blockIdentifier**

Expand All @@ -62,7 +62,7 @@ A non-constant method requires a transaction to be signed and requires payment i

contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < AddTransactionResponse >_

Returns a AddTransactionResponse for the transaction after it is sent to the network. This requires the Contract has a signer.
Returns a _AddTransactionResponse_ for the transaction after it is sent to the network. This requires that Contract has a signer.

The _overrides_ object for write methods may include any of:

Expand Down
2 changes: 1 addition & 1 deletion www/docs/API/contractFactory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 5

# Contract Factory

Contract Factory allow you to deploy contracts onto StarkNet. To deploy a Contract, additional information is needed that is not available on a Contract object itself.
Contract Factory allow you to deploy contracts to StarkNet. To deploy a Contract, additional information is needed that is not available on a Contract object itself.

## Creating an instance

Expand Down
28 changes: 14 additions & 14 deletions www/docs/API/provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ sidebar_position: 1

# Provider

The **Provider** API allows you to interface with the StarkNet network, without signing transactions or messages.
The **Provider** API allows you to interact with the StarkNet network, without signing transactions or messages.

Typically, these are _read_ calls on the blockchain.

## Creating an instance

`new starknet.Provider(optionsOrProvider)`

The options for the provider depends from the network. The structure of the options object is:
The options for the provider depend on the network. The structure of the options object is:

- options.**sequencer** - Options for sequencer provider
- options.**rpc** - Options for RPC provider
Expand All @@ -35,23 +35,23 @@ const provider = new starknet.Provider({
})
```

If you want to more control:
If you want more control:

```typescript
const provider = new starknet.Provider({
sequencer: {
sequencer: {
baseUrl: 'https://alpha4.starknet.io',
feederGatewayUrl: 'feeder_gateway',
gatewayUrl: 'gateway',
}
})
```

These are also default options for the Provider constructor with `network: 'goerli-alpha'`.
These are also the default options for the Provider constructor with `network: 'goerli-alpha'`.

> **Note**
>
> `network` arguement should work in most cases. If you want to use sequencer arguement with `baseUrl`, you will not be able to use `network` field in the object.
> `network` arguement should work in most cases. If you want to use the `sequencer` arguement with `baseUrl`, you will not be able to use the `network` field in the object.
## Methods

Expand All @@ -65,7 +65,7 @@ The call object structure:

- call.**contractAddress** - Address of the contract
- call.**entrypoint** - Entrypoint of the call (method name)
- call.**calldata** - Payload for the invoking the method
- call.**calldata** - Payload for the invoking method

###### _CallContractResponse_

Expand Down Expand Up @@ -168,7 +168,7 @@ Gets the transaction information from a tx hash.

provider.**declareContract**(payload) => _Promise < DeclareContractResponse >_

Declares a contract on Starknet
Declares a contract on Starknet.

###### _DeclareContractResponse_

Expand All @@ -183,7 +183,7 @@ Declares a contract on Starknet

provider.**deployContract**(payload [ , abi ]) => _Promise < DeployContractResponse >_

Deploys a contract on Starknet
Deploys a contract on Starknet.

###### _DeployContractResponse_

Expand All @@ -206,15 +206,15 @@ Wait for the transaction to be accepted on L2 or L1.

`new starknet.SequencerProvider(optionsOrProvider)`

The options for the provider depends from the network. The structure of the options object is:
The options for the provider depend on the network. The structure of the options object is:

- options.**baseUrl** - Base URL of the network
- options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
- options.**gatewayUrl** - Gateway Endpoint

or

- options.**network** - One of 'mainnet-alpha' or 'goerli-alpha'
- options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'

Example:

Expand All @@ -228,7 +228,7 @@ const provider = new starknet.Provider({

## Methods

Gets the smart contract address on the network
Gets the smart contract address on the network.

provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_

Expand Down Expand Up @@ -284,8 +284,8 @@ Gets the transaction trace from a tx hash.
internal_call: Array<any>;
events: Array<any>;
messages: Array<any>;
};
signature: Signature;
};
signature: Signature;
}
```

Expand Down
6 changes: 3 additions & 3 deletions www/docs/API/signer.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ The **Signer** API allows you to sign transactions and messages, and also allows

signer.**getPubKey**() => _Promise < string >_

Returns public key of the signer.
Returns the public key of the signer.

<hr />

signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_

Returns signature of the transaction.
Returns the signature of the transaction.

###### _Signature_

Expand All @@ -32,7 +32,7 @@ string[]

signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_

Returns signature of the transaction.
Returns the signature of the transaction.

###### _Signature_

Expand Down
36 changes: 20 additions & 16 deletions www/docs/API/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Util functions are provided so you can use various low level functions in your a

## **address**

The address helpers can be imported using:
Helper functions for starknet addresses.

```js
import { address } from 'starknet.js';
```
### validateAndParseAddress

`validateAndParseAddress(address: BigNumberish): string`

Checks if the address is valid and, if it is, parses it to the correct format (0x prefix is added if not provided).

### getChecksumAddress

Expand Down Expand Up @@ -55,13 +57,13 @@ Function to compress compiled cairo program. Accepts a json file representing th

`randomAddress(): string`

Function that generates a random contract address.
Function that generates a random stark address.

### makeAddress

`makeAddress(input: string): string`

Function that turns an incompatible address string into stark address format.
Function that turns an incompatible address string into stark address format.

Returns a string.

Expand All @@ -71,7 +73,7 @@ Example: `0xdFD0F27FCe99b50909de0bDD328Aed6eAbe76BC5` -> `0xdfd0f27fce99b50909de

`formatSignature(sig?: Signature): string[]`

Function that formats a Signature to BigNum and then to string array.
Function that formats a Signature to BigNum and then to string array.

Returns a string array.

Expand Down Expand Up @@ -122,15 +124,15 @@ Check if number is in hex format.

`toBN(number: BigNumberish, base?: number | 'hex'): BN`

Converts BigNumberish to BN.
Converts BigNumberish to BN.

Returns a BN.

### toHex

`toHex(number: BN): string`

Converts BN to hex.
Converts BN to hex.

Returns a string.

Expand All @@ -144,7 +146,7 @@ Converts hex string to decimal string.

`toFelt(num: BigNumberish): string`

Converts BN to Felt.
Converts BN to Felt.

Returns a string.

Expand Down Expand Up @@ -174,6 +176,8 @@ const signature = await this.signer.signTransaction(transactions, signerDetails)
}
```

<hr />

## **uint256**

```js
Expand Down Expand Up @@ -222,23 +226,23 @@ Returns starknet keccak hash as BigNumber.

`getSelectorFromName(funcName: string)`

Function to get the hex selector from a given function name.
Function to get the hex selector from a given function name.

Returns hex selector of given abi function name.

### pedersen

`pedersen(input: [BigNumberish, BigNumberish])`

Function to get the Pedersen hash for two arguments.
Function to get the Pedersen hash for two arguments.

Returns a string.

### computeHashOnElements

`computeHashOnElements(data: BigNumberish[])`

Function to compute a Pedersen hash on a array of elements.
Function to compute a Pedersen hash on a array of elements.

Returns a string.

Expand Down Expand Up @@ -313,7 +317,7 @@ Public key defined over a Stark-friendly elliptic curve that is different from t

Takes a public key and casts it into `elliptic` KeyPair format.

Returns keyPair with public key only, which can be used to verify signatures, but cant sign anything.
Returns keyPair with public key only, which can be used to verify signatures, but can't sign anything.

### sign

Expand All @@ -334,5 +338,5 @@ Verifies a message using the provided key.
keyPair should be an KeyPair with a valid public key.

sig should be an Signature.
Returns true if the verification succeeds.

Returns true if the verification succeeds.

0 comments on commit 72f3d4b

Please sign in to comment.