solidity-scale-codec 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +10 -28
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
[Unreleased]
|
|
9
9
|
|
|
10
|
+
## Version 1.0.1
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- More docs and examples - [#5006d28](https://github.com/LucasGrasso/solidity-scale-codec/commit/5006d28)
|
|
15
|
+
|
|
10
16
|
## Version 1.0.0
|
|
11
17
|
|
|
12
18
|
### Added
|
package/README.md
CHANGED
|
@@ -26,10 +26,16 @@ See the [Definitions](https://lucasgrasso.github.io/solidity-scale-codec/Definit
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
Check out the examples section of the documentation for how to use the library to encode and decode different types, and how to build XCM messages in Solidity.
|
|
30
|
+
|
|
31
|
+
### Encode Structs
|
|
30
32
|
|
|
31
33
|
See this [example](https://github.com/LucasGrasso/solidity-scale-codec/blob/main/contracts/examples/Foo.sol).
|
|
32
34
|
|
|
35
|
+
### Encode XCM messages
|
|
36
|
+
|
|
37
|
+
Check out the [Xcm Builder](https://lucasgrasso.github.io/solidity-scale-codec/Xcm/v5/Xcm/XcmBuilder.html) for an ergonomic API to build XCM messages in Solidity, and how you can use it in this [example](https://github.com/LucasGrasso/solidity-scale-codec/blob/main/test/VersionedXcm.t.sol#L120)
|
|
38
|
+
|
|
33
39
|
## About the libraries
|
|
34
40
|
|
|
35
41
|
### src/LittleEndian
|
|
@@ -95,34 +101,9 @@ Implementation notes:
|
|
|
95
101
|
- Enum-like XCM types are represented as structs with a type discriminator plus `bytes payload`.
|
|
96
102
|
- Each type has a codec library with `encode`, `encodedSizeAt`, `decode`, and `decodeAt`.
|
|
97
103
|
- `VersionedXcm` currently supports v5 payloads.
|
|
104
|
+
- The `XcmBuilder` library provides an ergonomic API to build XCM messages in Solidity, with functions for building various XCM instructions.
|
|
98
105
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
```solidity
|
|
102
|
-
import {Instruction} from "../src/Xcm/v5/Instruction/Instruction.sol";
|
|
103
|
-
import {Xcm, fromInstructions} from "../src/Xcm/v5/Xcm/Xcm.sol";
|
|
104
|
-
import {v5} from "../src/Xcm/VersionedXcm/VersionedXcm.sol";
|
|
105
|
-
import {VersionedXcmCodec} from "../src/Xcm/VersionedXcm/VersionedXcmCodec.sol";
|
|
106
|
-
import {Weight} from "../src/Xcm/v5/Weight/Weight.sol";
|
|
107
|
-
import {WeightCodec} from "../src/Xcm/v5/Weight/WeightCodec.sol";
|
|
108
|
-
|
|
109
|
-
address constant XCM_PRECOMPILE_ADDRESS = 0x00000000000000000000000000000000000a0000;
|
|
110
|
-
|
|
111
|
-
contract XcmWeightEstimator {
|
|
112
|
-
function weighMessage(
|
|
113
|
-
Instruction[] memory instructions
|
|
114
|
-
) external view returns (Weight memory) {
|
|
115
|
-
Xcm memory xcm = fromInstructions(instructions);
|
|
116
|
-
(bool success, bytes memory result) = XCM_PRECOMPILE_ADDRESS.staticcall(
|
|
117
|
-
VersionedXcmCodec.encode(v5(xcm))
|
|
118
|
-
);
|
|
119
|
-
require(success, "XCM precompile call failed");
|
|
120
|
-
(Weight memory weight, ) = WeightCodec.decode(result);
|
|
121
|
-
return weight;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
```
|
|
106
|
+
````
|
|
126
107
|
|
|
127
108
|
### Running Tests
|
|
128
109
|
|
|
@@ -144,3 +125,4 @@ npx hardhat test nodejs
|
|
|
144
125
|
Copyright 2025 Lucas Grasso
|
|
145
126
|
|
|
146
127
|
This project is licensed under the the [Apache License, Version 2.0](LICENSE).
|
|
128
|
+
````
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solidity-scale-codec",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Solidity implementation of scale-codec.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"solidity",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"hardhat": "^3.0.15",
|
|
48
48
|
"prettier": "^3.8.1",
|
|
49
49
|
"prettier-plugin-solidity": "^2.2.1",
|
|
50
|
-
"solidity-doc-generator": "^1.2.
|
|
50
|
+
"solidity-doc-generator": "^1.2.4",
|
|
51
51
|
"typescript": "~5.8.0",
|
|
52
52
|
"viem": "^2.40.3",
|
|
53
53
|
"vitepress": "^1.6.4",
|