Skip to content

Commit e165d36

Browse files
committed
docs: update dependencies
1 parent 670a3ed commit e165d36

File tree

83 files changed

+9825
-6617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+9825
-6617
lines changed

src/provider/interface.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export abstract class ProviderInterface {
133133
* Get the value of the storage (contract's variable) at the given address and key
134134
*
135135
* @param contractAddress
136-
* @param key - from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
136+
* @param key - from starknetKeccak()
137137
* @param blockIdentifier - block identifier
138138
* @returns the value of the storage variable
139139
*/
@@ -147,7 +147,7 @@ export abstract class ProviderInterface {
147147
* Gets the transaction information from a tx id.
148148
*
149149
* @param transactionHash
150-
* @returns the transaction object \{ transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? \}
150+
* @returns the transaction object `{ transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }`
151151
*/
152152
public abstract getTransaction(transactionHash: BigNumberish): Promise<GetTransactionResponse>;
153153

src/utils/cairoDataTypes/uint256.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class CairoUint256 {
107107

108108
/**
109109
* Return Uint256 structure with HexString props
110-
* {low: HexString, high: HexString}
110+
* `{low: HexString, high: HexString}`
111111
*/
112112
toUint256HexString() {
113113
return {
@@ -118,7 +118,7 @@ export class CairoUint256 {
118118

119119
/**
120120
* Return Uint256 structure with DecimalString props
121-
* {low: DecString, high: DecString}
121+
* `{low: DecString, high: DecString}`
122122
*/
123123
toUint256DecimalString() {
124124
return {

src/utils/calldata/byteArray.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ export function stringFromByteArray(myByteArray: ByteArray): string {
3737
* @example
3838
* ```typescript
3939
* const myByteArray: ByteArray = byteArrayFromString("ABCDEFGHI");
40+
* // result is: {
41+
* // data: [],
42+
* // pending_word: '0x414243444546474849',
43+
* // pending_word_len: 9
44+
* // }
4045
* ```
41-
* Result is :
42-
* {
43-
* data: [],
44-
* pending_word: '0x414243444546474849',
45-
* pending_word_len: 9
46-
* }
4746
*/
4847
export function byteArrayFromString(targetString: string): ByteArray {
4948
const shortStrings: string[] = splitLongString(targetString);

src/utils/calldata/enum/CairoCustomEnum.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export type CairoEnumRaw = {
44

55
/**
66
* Class to handle Cairo custom Enum
7-
* @param enumContent object containing the variants and its content. Example :
8-
* {Success: 234, Warning: undefined, Error: undefined}.
7+
* @param enumContent object containing the variants and its content. Example:
8+
* `{Success: 234, Warning: undefined, Error: undefined}`.
99
* Only one variant with a value, object, array.
1010
* @returns an instance representing a Cairo custom Enum.
1111
* @example

src/utils/provider.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,11 @@ export const getDefaultNodeUrl = (networkName?: NetworkName, mute: boolean = fal
131131
export const validBlockTags = Object.values(BlockTag);
132132

133133
/**
134-
* This class is formatting the identifier of a block.
135-
*
136-
* hex string and BigInt are detected as block hashes. identifier return { block_hash: hash }
137-
*
138-
* decimal string and number are detected as block numbers. identifier return { block_number: number }
139-
*
140-
* text string are detected as block tag. identifier return tag
141-
*
142-
* null is detected as 'pending' block tag. identifier return 'pending'
134+
* This class formats the identifier of a block.
135+
* - hex strings and BigInts are detected as block hashes. identifier return `{ block_hash: hash }`
136+
* - decimal strings and numbers are detected as block numbers. identifier return `{ block_number: number }`
137+
* - text strings are detected as block tag. identifier return tag
138+
* - null is detected as 'pending' block tag. identifier return 'pending'
143139
* @example
144140
* ```typescript
145141
* const result = new provider.Block(null).identifier;

www/ApiTitle.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# Starknet.js API
2+
13
This API is based on the <ins>[Starknet.js V3](https://github.com/starknet-io/starknet.js/discussions/102)</ins> Interface write up by <ins>[Janek](https://twitter.com/0xjanek)</ins> of <ins>[Argent](https://www.argent.xyz/)</ins>
24

35
## Provider
46

5-
The Provider [**API**](./classes/Provider.md) allows you to interact with the Starknet network, without signing transactions or messages.
7+
The Provider [**API**](./classes/Provider.md) [**API2**](./docs/API/classes/Provider.md) allows you to interact with the Starknet network, without signing transactions or messages.
68

79
Typically, these are _read_ calls on the blockchain.
810

@@ -34,18 +36,18 @@ The Signer [**API**](./classes/Signer.md) allows you to sign transactions and me
3436

3537
Util functions are provided so you can use various low level functions in your application:
3638

37-
### [elliptic curve](./namespaces/ec.md)
39+
### [elliptic curve](./namespaces/ec/)
3840

39-
### [hash](./namespaces/hash.md)
41+
### [hash](./namespaces/hash/)
4042

41-
### [num](./namespaces/num.md)
43+
### [num](./namespaces/num/)
4244

43-
### [encode](./namespaces/encode.md)
45+
### [encode](./namespaces/encode/)
4446

45-
### [merkle](./namespaces/merkle.md)
47+
### [merkle](./namespaces/merkle/)
4648

47-
### [shortString](./namespaces/shortString.md)
49+
### [shortString](./namespaces/shortString/)
4850

49-
### [stark](./namespaces/stark.md)
51+
### [stark](./namespaces/stark/)
5052

51-
### [uint256](./namespaces/uint256.md)
53+
### [uint256](./namespaces/uint256/)

www/docs/guides/define_call_message.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -538,21 +538,21 @@ const amount = res.amount;
538538
const amount = myContract.call(...);
539539
```
540540

541-
| Type in Cairo 1 | Cairo 1 code | Type expected in JS/TS | JS/TS function to recover data |
542-
| --------------------------------------------------------- | ---------------------------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
543-
| u8, u16, u32, usize, u64, u128, felt252, address | `func get_v()->u128` | bigint | `const res: bigint = myContract.call(...` |
544-
| | | string representing an hex number | `const res=myContract.call(...`<br /> `const address: string = num.toHex(res);` |
545-
| u8, u16, u32, usize | `func get_v() -> u16` | number (53 bits max) | `const res=myContract.call(...`<br /> `const total: number = Number(res)` |
546-
| u256 (255 bits max) | `func get_v() -> u256` | bigint | `const res: bigint = myContract.call(...` |
547-
| u512 (512 bits max) | `func get_v() -> u512` | bigint | `const res: bigint = myContract.call(...` |
548-
| array of u8, u16, u32, usize, u64, u128, felt252, address | `func get_v() -> Array<u64>` | bigint[] | `const res: bigint[] = myContract.call(...` |
549-
| bytes31 (31 ASCII characters max) | `func get_v() -> bytes31` | string | `const res: string = myContract.call(...` |
550-
| felt252 (31 ASCII characters max) | `func get_v() -> felt252` | string | `const res = myContract.call(...`<br /> `const title:string = shortString.decodeShortstring(res);` |
551-
| longString | `func get_v() -> Array<felt252>` | string | `const res=myContract.call(...`<br /> `const longString = res.map( (shortStr: bigint) => { return shortString.decodeShortString( num.toHex( shortStr)) }).join("");` |
552-
| ByteArray | `func get_v() -> ByteArray` | string | `const res: string = myContract.call(...` |
553-
| Tuple | `func get_v() -> (felt252, u8)` | Object {"0": bigint, "1": bigint} | `const res = myContract.call(...` <br /> `const res0: bigint = res["0"];` <br /> `const results: bigint[] = Object.values(res)` |
554-
| Struct | ` func get_v() -> MyStruct` | MyStruct = { account: bigint, amount: bigint} | `const res: MyStruct = myContract.call(...` |
555-
| complex array | `func get_v() -> Array<fMyStruct>` | MyStruct[] | `const res: MyStruct[] = myContract.call(...` |
541+
| Type in Cairo 1 | Cairo 1 code | Type expected in JS/TS | JS/TS function to recover data |
542+
| --------------------------------------------------------- | ---------------------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
543+
| u8, u16, u32, usize, u64, u128, felt252, address | `func get_v()->u128` | `bigint` | `const res: bigint = myContract.call(...` |
544+
| | | `string representing an hex number` | `const res=myContract.call(...`<br /> `const address: string = num.toHex(res);` |
545+
| u8, u16, u32, usize | `func get_v() -> u16` | `number (53 bits max)` | `const res=myContract.call(...`<br /> `const total: number = Number(res)` |
546+
| u256 (255 bits max) | `func get_v() -> u256` | `bigint` | `const res: bigint = myContract.call(...` |
547+
| u512 (512 bits max) | `func get_v() -> u512` | `bigint` | `const res: bigint = myContract.call(...` |
548+
| array of u8, u16, u32, usize, u64, u128, felt252, address | `func get_v() -> Array<u64>` | `bigint[]` | `const res: bigint[] = myContract.call(...` |
549+
| bytes31 (31 ASCII characters max) | `func get_v() -> bytes31` | `string` | `const res: string = myContract.call(...` |
550+
| felt252 (31 ASCII characters max) | `func get_v() -> felt252` | `string` | `const res = myContract.call(...`<br /> `const title:string = shortString.decodeShortstring(res);` |
551+
| longString | `func get_v() -> Array<felt252>` | `string` | `const res=myContract.call(...`<br /> `const longString = res.map( (shortStr: bigint) => { return shortString.decodeShortString( num.toHex( shortStr)) }).join("");` |
552+
| ByteArray | `func get_v() -> ByteArray` | `string` | `const res: string = myContract.call(...` |
553+
| Tuple | `func get_v() -> (felt252, u8)` | `Object {"0": bigint, "1": bigint}` | `const res = myContract.call(...` <br /> `const res0: bigint = res["0"];` <br /> `const results: bigint[] = Object.values(res)` |
554+
| Struct | `func get_v() -> MyStruct` | `MyStruct = { account: bigint, amount: bigint}` | `const res: MyStruct = myContract.call(...` |
555+
| complex array | `func get_v() -> Array<fMyStruct>` | `MyStruct[]` | `const res: MyStruct[] = myContract.call(...` |
556556

557557
If you don't know if your Contract object is interacting with a Cairo 0 or a Cairo 1 contract, you have these methods:
558558

www/docusaurus.config.js

+50-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4-
const lightCodeTheme = require('prism-react-renderer/themes/github');
5-
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
4+
const lightCodeTheme = require('prism-react-renderer').themes.github;
5+
const darkCodeTheme = require('prism-react-renderer').themes.dracula;
66

77
const generateBaseUrl = (baseUrl = '') => `/${baseUrl.trim()}/`.replace(/\/+/g, '/');
88

@@ -13,6 +13,35 @@ const generateSourceLinkTemplate = (gitRevision) =>
1313

1414
const migrationGuideLink = `${generateBaseUrl(process.env.DOCS_BASE_URL)}docs/guides/migrate`;
1515

16+
/**
17+
* @param {import('@docusaurus/plugin-content-docs/src/sidebars/types.js').SidebarItemsGeneratorArgs} args
18+
* @param {import('@docusaurus/plugin-content-docs/src/sidebars/types.js').NormalizedSidebar} items
19+
*/
20+
function injectTypeDocSidebar(args, items) {
21+
if (args.version.versionName !== 'current') return items;
22+
23+
return items.toReversed().map((item) => {
24+
if (
25+
item.type === 'category' &&
26+
item.link?.type === 'doc' &&
27+
item.link?.id === 'API/index' &&
28+
item.label === 'Starknet.js API'
29+
) {
30+
item.label = 'API';
31+
32+
const groupedItems = item.items.reduce((grouped, entry) => {
33+
// @ts-ignore
34+
grouped[entry.label || 'globals'] = entry;
35+
return grouped;
36+
}, {});
37+
const order = ['globals', 'namespaces', 'classes'];
38+
if (order.length !== item.items.length) throw new Error('Sidebar mapping error');
39+
item.items = order.map((x) => groupedItems[x]);
40+
}
41+
return item;
42+
});
43+
}
44+
1645
/** @type {import('@docusaurus/types').Config} */
1746
const config = {
1847
title: 'Starknet.js',
@@ -33,13 +62,18 @@ const config = {
3362
theme: {
3463
customCss: require.resolve('./src/css/custom.css'),
3564
},
65+
docs: {
66+
async sidebarItemsGenerator({ defaultSidebarItemsGenerator, ...args }) {
67+
return injectTypeDocSidebar(args, await defaultSidebarItemsGenerator(args));
68+
},
69+
},
3670
}),
3771
],
3872
],
3973

4074
themeConfig:
4175
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
42-
{
76+
({
4377
algolia: {
4478
// The application ID provided by Algolia
4579
appId: '86VVNRI64B',
@@ -153,18 +187,17 @@ const config = {
153187
theme: lightCodeTheme,
154188
darkTheme: darkCodeTheme,
155189
},
156-
},
190+
}),
157191

158192
plugins: [
159193
[
160194
'docusaurus-plugin-typedoc',
161-
{
195+
/** @type {Partial<import('typedoc').TypeDocOptions & import('docusaurus-plugin-typedoc').PluginOptions>} */
196+
({
162197
entryPoints: ['../src/index.ts'],
163198
tsconfig: '../tsconfig.json',
164-
out: 'API',
165-
name: 'Starknet.js API',
199+
out: 'docs/API',
166200
includeVersion: true,
167-
includeExtension: true,
168201
sourceLinkTemplate: generateSourceLinkTemplate(
169202
process.env.GIT_REVISION_OVERRIDE || 'develop'
170203
),
@@ -173,33 +206,16 @@ const config = {
173206
private: false,
174207
},
175208
sort: ['kind'],
176-
kindSortOrder: [
177-
'Reference',
178-
'Project',
179-
'Module',
180-
'Class',
181-
'Namespace',
182-
'Enum',
183-
'EnumMember',
184-
'Interface',
185-
'TypeAlias',
186-
'Constructor',
187-
'Property',
188-
'Variable',
189-
'Function',
190-
'Accessor',
191-
'Method',
192-
'Parameter',
193-
'TypeParameter',
194-
'TypeLiteral',
195-
'CallSignature',
196-
'ConstructorSignature',
197-
'IndexSignature',
198-
'GetSignature',
199-
'SetSignature',
200-
],
209+
sidebar: {
210+
autoConfiguration: true,
211+
},
201212
readme: './ApiTitle.md',
202-
},
213+
parametersFormat: 'table',
214+
interfacePropertiesFormat: 'table',
215+
enumMembersFormat: 'table',
216+
typeDeclarationFormat: 'table',
217+
membersWithOwnFile: ['Class', 'Enum', 'Interface'],
218+
}),
203219
],
204220
],
205221
};

0 commit comments

Comments
 (0)