-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
288 additions
and
771 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@starknet-react/core': minor | ||
'website': minor | ||
--- | ||
|
||
Change hooks interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import { createContext, useContext } from 'react' | ||
import { GetBlockResponse } from 'starknet' | ||
|
||
export const StarknetBlockContext = createContext<GetBlockResponse | undefined>(undefined) | ||
export interface StarknetBlock { | ||
data?: GetBlockResponse | ||
loading?: boolean | ||
error?: string | ||
} | ||
|
||
export const StarknetBlockContext = createContext<StarknetBlock>(undefined) | ||
|
||
export function useStarknetBlock(): GetBlockResponse | undefined { | ||
export function useStarknetBlock(): StarknetBlock { | ||
return useContext(StarknetBlockContext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# useStarknetBlock | ||
|
||
Hook to access the current StarkNet block. | ||
|
||
```typescript | ||
import { useStarknetBlock } from '@starknet-react/core' | ||
|
||
const { data, loading, error } = useStarknetBlock() | ||
``` | ||
|
||
## Return Values | ||
|
||
```typescript | ||
{ | ||
data?: GetBlockResponse | ||
loading?: boolean | ||
error?: string | ||
} | ||
``` | ||
|
||
Where `GetBlockResponse` is from starknet.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# useStarknetCall | ||
|
||
Hook to fetch data from a StarkNet contract. The data is automatically refreshed at every block. | ||
|
||
```typescript | ||
import { useStarknetCall } from '@starknet-react/core' | ||
|
||
const { data, loading, error, refresh } = useStarknetCall({ contract, method, args }) | ||
``` | ||
|
||
## Parameters | ||
|
||
```typescript | ||
{ | ||
contract?: Contract | ||
method?: string | ||
args?: Args | ||
} | ||
``` | ||
|
||
## Return Values | ||
|
||
```typescript | ||
{ | ||
data?: Args | ||
loading: boolean | ||
error?: string | ||
refresh: () => void | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# useContract | ||
|
||
Hook to build a `Contract` instance from its ABI and address. | ||
|
||
```typescript | ||
import { useContract } from '@starknet-react/core' | ||
|
||
const { contract } = useContract({ abi, address }) | ||
``` | ||
|
||
## Parameters | ||
|
||
```typescript | ||
{ | ||
abi?: Abi[] | ||
address?: string | ||
} | ||
``` | ||
|
||
Where `Abi` is from starknet.js. | ||
|
||
## Return Values | ||
|
||
```typescript | ||
{ | ||
contract?: Contract | ||
} | ||
``` | ||
|
||
A contract is returned only if both `abi` and `address` are defined. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# useStarknetInvoke | ||
|
||
Hook to create a function that invokes a contract method and track the transaction status. | ||
|
||
```typescript | ||
import { useStarknetInvoke } from '@starknet-react/core' | ||
|
||
const { data, loading, error, reset, invoke } = useStarknetInvoke({ contract, method }) | ||
``` | ||
|
||
## Parameters | ||
|
||
```typescript | ||
{ | ||
contract?: Contract | ||
method?: string | ||
} | ||
``` | ||
|
||
## Return Values | ||
|
||
```typescript | ||
data?: Args | ||
loading: boolean | ||
error?: string | ||
reset: () => void | ||
invoke: (args: Args) => Promise<AddTransactionResponse | undefined> | ||
``` | ||
|
||
Where `Args` and `AddTransactionResponse` are from starknet.js. |
Oops, something went wrong.