Skip to content

Commit 96c5701

Browse files
committed
docs: add migration to V6
1 parent 7e10e53 commit 96c5701

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

www/docs/guides/migrate.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,84 @@
22
sidebar_position: 18
33
---
44

5+
# Migrate from v5 to v6
6+
7+
This document only covers the features present in v5 which have changed in some significant way in v6.
8+
If you encounter any missing changes, please let us know and we will update this guide.
9+
10+
## Transaction response
11+
12+
When you send a transaction, the response type has changed.
13+
Previously, the response was just the transaction hash value. Now, the response is an object including many other data.
14+
This has an impact on `provider.waitForTransaction()` :
15+
16+
```typescript
17+
const response = await ethContract.approve(swapContractAddress, cairo.uint256(100000));
18+
// v5
19+
const transactionReceipt = await provider.waitForTransaction(response);
20+
21+
// v6
22+
const transactionReceipt = await provider.waitForTransaction(response.transaction_hash);
23+
```
24+
25+
## Long strings
26+
27+
Starknet.js v6 is compatible with Cairo v2.4.0. It means that the long strings (>31 characters) are automatically handled and converted to the Cairo `ByteArray` type.
28+
So, the command to convert a long string to an array of felts (for Cairo 0 contracts for example) has changed :
29+
30+
```typescript
31+
// v5
32+
const param: BigNumberish[] = CallData.compile("http://addressOfMyERC721pictures/storage/image1.jpg");
33+
// v6
34+
const param: BigNumberish[] = CallData.compile(shortString.splitLongString("http://addressOfMyERC721pictures/storage/image1.jpg"));
35+
```
36+
37+
## Fees
38+
39+
All functions related to gas price and estimation of fees have changed their output types.
40+
For example, if you read the content of a block, the ETH gasPrice was straightforward to read. With v6, it's now more nested :
41+
42+
```typescript
43+
const resp: GetBlockResponse = await myProvider.getBlock("latest");
44+
// v5
45+
const gasPrice = resp.gas_price;
46+
// v6
47+
const gasPrice = resp.l1_gas_price.price_in_wei;
48+
```
49+
50+
Other example for `estimateDeclareFee()`, where the object response has changed :
51+
52+
```typescript
53+
const fee = await account0.estimateDeclareFee({ contract: compiledContract });
54+
// v5 response
55+
fee = {
56+
overall_fee: 247700000000000n,
57+
gas_consumed: 2477n,
58+
gas_price: 100000000000n,
59+
suggestedMaxFee: 371550000000000n
60+
}
61+
// v6 response
62+
fee = {
63+
overall_fee: 247700000000000n,
64+
gas_consumed: 2477n,
65+
gas_price: 100000000000n,
66+
unit: undefined,
67+
suggestedMaxFee: 371550000000000n,
68+
resourceBounds: {
69+
l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' },
70+
l1_gas: { max_amount: '0xaa4', max_price_per_unit: '0x22ecb25c00' }
71+
}
72+
}
73+
```
74+
75+
So you have to adapt your code to all these new entries. Globally, pay attention of all the result types of methods that returns a response from the node.
76+
77+
<br />
78+
<br />
79+
<br />
80+
<hr>
81+
<hr>
82+
583
# Migrate from v4 to v5
684

785
This document only covers the features present in v4 which have changed in some significant way in v5.

www/docusaurus.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const config = {
6868
//... other Algolia param
6969
},
7070
announcementBar: {
71-
content: `<a href="${migrationGuideLink}">Migrate from v4</a>`,
71+
content: `<a href="${migrationGuideLink}">Migrate from v5</a>`,
7272
backgroundColor: 'rgb(230 231 232)',
7373
},
7474
navbar: {
@@ -118,7 +118,7 @@ const config = {
118118
to: '/docs/guides/intro',
119119
},
120120
{
121-
label: 'Migrate from v4',
121+
label: 'Migrate from v5',
122122
to: migrationGuideLink,
123123
},
124124
],

0 commit comments

Comments
 (0)