Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solidity-dynamic-array

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solidity-dynamic-array - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

2

package.json
{
"name": "solidity-dynamic-array",
"version": "0.2.0",
"version": "0.3.0",
"author": {

@@ -5,0 +5,0 @@ "name": "Kamil Planer",

@@ -161,2 +161,36 @@ # <center> Solidity dynamic array </center>

**fromSequence**
```solidity
function fromSequence(uint256 end) internal pure returns (struct LinkedList newList)
```
Creates a list of numbers from 0 to end
| Name | Type | Description |
| ---- | ------- | ------------------------------ |
| end | uint256 | The number to end the sequence |
| Name | Type | Description |
| ------- | ----------------- | -------------------------------------- |
| newList | struct LinkedList | The new list created from the sequence |
**fromSubrange**
```solidity
function fromSubrange(struct LinkedList list, uint256 start, uint256 end) internal pure returns (struct LinkedList)
```
Creates a new list of numbers witch is a subset of the original list from specified part
| Name | Type | Description |
| ----- | ----------------- | -------------------------------- |
| list | struct LinkedList | The list to create a subset from |
| start | uint256 | The index to start the subset |
| end | uint256 | The index to end the subset |
| Name | Type | Description |
| ---- | ----------------- | -------------------------------------------- |
| [0] | struct LinkedList | newList the new list created from the subset |
**push**

@@ -478,2 +512,19 @@

**find**
```solidity
function find(struct LinkedList list, function (bytes,uint256) pure returns (bool) callback) internal pure returns (bytes)
```
Finds the first occurance of the specified in the list
| Name | Type | Description |
| -------- | -------------------------------------------- | ------------------------------------------------- |
| list | struct LinkedList | The list to search |
| callback | function (bytes,uint256) pure returns (bool) | The callback to call for each element in the list |
| Name | Type | Description |
| ---- | ----- | ----------------------------------------------------------------------------------------------------------------------------- |
| [0] | bytes | the first value from the list for which the callback returns true, or an empty bytes array if the callback never returns true |
**contains**

@@ -539,2 +590,92 @@

**asAddressArray**
```solidity
function asAddressArray(struct LinkedList list) internal pure returns (address[] result)
```
Creates a solidity array of addresses from the linked list
_This function should only be called if the list contains addresses_
| Name | Type | Description |
| ---- | ----------------- | ------------------- |
| list | struct LinkedList | the list to convert |
| Name | Type | Description |
| ------ | --------- | ---------------------- |
| result | address[] | the array of addresses |
**asUintArray**
```solidity
function asUintArray(struct LinkedList list) internal pure returns (uint256[] result)
```
Creates a solidity array of unsigned integers from the linked list
_This function should only be called if the list contains unsigned integers_
| Name | Type | Description |
| ---- | ----------------- | ------------------- |
| list | struct LinkedList | the list to convert |
| Name | Type | Description |
| ------ | --------- | ------------------------------ |
| result | uint256[] | the array of unsigned integers |
**asIntArray**
```solidity
function asIntArray(struct LinkedList list) internal pure returns (int256[] result)
```
Creates a solidity array of integers from the linked list
_This function should only be called if the list contains integers_
| Name | Type | Description |
| ---- | ----------------- | ------------------- |
| list | struct LinkedList | the list to convert |
| Name | Type | Description |
| ------ | -------- | --------------------- |
| result | int256[] | the array of integers |
**asBoolArray**
```solidity
function asBoolArray(struct LinkedList list) internal pure returns (bool[] result)
```
Creates a solidity array of boolean values from the linked list
_This function should only be called if the list contains boolean values_
| Name | Type | Description |
| ---- | ----------------- | ------------------- |
| list | struct LinkedList | the list to convert |
| Name | Type | Description |
| ------ | ------ | --------------------------- |
| result | bool[] | the array of boolean values |
**asStringArray**
```solidity
function asStringArray(struct LinkedList list) internal pure returns (string[] result)
```
Creates a solidity array of strings from the linked list
_This function should only be called if the list contains strings_
| Name | Type | Description |
| ---- | ----------------- | ------------------- |
| list | struct LinkedList | the list to convert |
| Name | Type | Description |
| ------ | -------- | -------------------- |
| result | string[] | the array of strings |
**slice**

@@ -801,2 +942,13 @@

## LinkedList struct can't be stored in storage
When trying to add LinkedList as a storage variable in a contract, you'll encounter an error:
```text
Compiler run failed
UnimplementedFeatureError: Copying of type struct Node memory[] memory to storage not yet supported.
```
Unfortunately, there is no way of storing nested structs directly in storage. What you can do is transform the LinkedList to an array through one of the `as...` methods (e.g. `asAddressArray` or `asUintArray`) and store the result array as a plain solidity array. Also, if you're storing structs in LinkedList, then you'd have to implement such casting function by yourself.
## Author

@@ -803,0 +955,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc