```typescript
const orderedModules = await contract.getLinkedList("0xdead...beef");
// orderedModules = ["lootbox-dapplet", "tipping-dapplet", "video-comments"];
// ДО:
// HEAD -> "lootbox-dapplet"
// "lootbox-dapplet" -> "tipping-dapplet"
// "tipping-dapplet" -> "video-comments"
// "video-comments" -> TAIL
// "my-nifty-collection"
// ["lootbox-dapplet", "my-nifty-collection", "tipping-dapplet", "video-comments"];
// ПОСЛЕ:
// HEAD -> "lootbox-dapplet"
// "lootbox-dapplet" -> "my-nifty-collection" +
// "my-nifty-collection" -> "tipping-dapplet" +
// "tipping-dapplet" -> "video-comments"
// "video-comments" -> TAIL
// ИЗМЕНИЛОСЬ:
// "lootbox-dapplet" -> "my-nifty-collection" +
// "my-nifty-collection" -> "tipping-dapplet" +
// Вариант 1
struct Link {
int32 prev;
int32 next;
}
await contract.changeMyList(
["lootbox-dapplet", "my-nifty-collection", "tipping-dapplet"],
[
{ prev: 0, next: 1 },
{ prev: 1, next: 2 },
]
);
// Как кодировать HEAD и TAIL?
// Вариант 1.1
// HEAD -1
// TAIL -2
// 0..2147483648 - index in the dictionary
// Вариант 1.2
// HEAD 0
// TAIL 4294967296
// 1..4294967295 - index in the dictionary + 1
// ["lootbox-dapplet", "my-nifty-collection", "tipping-dapplet"]
// indexes: [0,1,2]
// [1,2,3]
// Вариант 2 проще. Но вопрос сколько газа потреблять будет
await contract.changeMyList([
{ prev: "lootbox-dapplet", next: "my-nifty-collection" },
{ prev: "my-nifty-collection", next: "tipping-dapplet" },
]);
// Вариант 3
changeMyList(string[2][] memory links) {
}
await contract.changeMyList([
["H", "my-nifty-collection"],
["my-nifty-collection", "T"],
]);
// addModuleInfo name.length > 1
if (abi.encodePacked(str) == 0x48) { // H
return _HEAD;
} else if (abi.encodePacked(str) == 0x54) { // T
return _TAIL;
} else {
return getModuleIndex(str);
}
// 0 - 0
// 1 - 0, 0xFFFFFFFF
// todo: head and tail
// frontend part
const tobeLinks: number[] = [];
const tobeIds = myListing.filter(x => x.type !== DappletsListItemTypes.Removing).map(x => x.id);
tobeIds.forEach((x, i) => {
tobeLinks[tobeIds[i - 1] ?? 0] = x;
tobeLinks[x] = tobeIds[i + 1] ?? 0xFFFFFFFF;
});
const asisLinks: number[] = [];
const asisIds = myOldListing.filter(x => x.type !== DappletsListItemTypes.Adding).map(x => x.id);
asisIds.forEach((x, i) => {
asisLinks[asisIds[i - 1] ?? 0] = x;
asisLinks[x] = asisIds[i + 1] ?? 0xFFFFFFFF;
});
const maxLength = (asisLinks.length > tobeLinks.length) ? asisLinks.length : tobeLinks.length;
const changedLinks = [];
for (let i = 0; i < maxLength; i++) {
if (asisLinks[i] !== tobeLinks[i]) {
changedLinks.push({
prev: i,
next: tobeLinks[i] ?? 0x00000000
});
}
}
```
```solidity=
// for .linkify() function
struct Link {
uint32 prev;
uint32 next;
}
// for .changeMyList() function
struct Link {
string prev;
string next;
}
struct LinkedListUint32 {
mapping(uint32 => uint32) map;
uint32 size;
bool initialized;
}
```