You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Releases.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,12 @@
2
2
3
3
## v0.7.0
4
4
5
-
This release changes the internal toolkit package to be part of the workspace - this fixes default-features flags in some of the
6
-
crates. In addition, crates used by the toolkit have been bumped, and the edition of the toolkit crates has been bumped to 2021
5
+
- This release changes the internal toolkit package to be part of the workspace - this fixes default-features flags in some of the crates. In addition, crates used by the toolkit have been bumped, and the edition of the toolkit crates has been bumped to 2021.
6
+
7
+
- Added the `Keyset` storage object (A hashset like storage object).
8
+
- Allowed further customisation of Keymap and Keyset with new constructor structs called `KeymapBuilder` and `KeysetBuilder` which allow the user to disable the iterator feature (saving gas) or adjust the internal indexes' page size so that the user may determine how many objects are to be stored/loaded together in the iterator.
9
+
-`::new_with_page_size(namespace, page_size)` method was added to `AppendStore` and `DequeStore` so that the user may adjust the internal indexes' page size which determine how many objects are to be stored/loaded together in the iterator.
10
+
- Minor performance upgrades to `Keymap`, `AppendStore`, and `DequeStore`.
Also known as a slot map, a generational index storage is an iterable data structure where each element in the list is identified by a unique key that is a pair (index, generation). Each time an item is removed from the list the generation of the storage increments by one. If a new item is placed at the same index as a previous item which had been removed previously, the old references will not point to the new element. This is because although the index matches, the generation does not. This ensures that each reference to an element in the list is stable and safe.
98
98
99
-
Starting with an empty set, if we insert A we will have key: (index: 0, generation: 0). Inserting B will have the key: (index: 1, generation: 0). When we remove A the generation will increment by 1 and index 0 will be freed up. When we insert C it will go to the head of our list of free slots and be given the key (index: 0, generation: 1). If you attempt to get A the result will be None, even though A and C have both been at "0" position in the list.
99
+
Starting with an empty set, if we insert A we will have key: (index: 0, generation: 0). Inserting B will have the key: (index: 1, generation: 0). When we remove A the generation will increment by 1 and index 0 will be freed up. When we insert C it will go to the head of our list of free slots and be given the key (index: 0, generation: 1). If you attempt to get A the result will be None, even though A and C have both been at "0" position in the list.
100
100
101
101
Unlike AppendStore, iteration over a generational index storage is not in order of insertion.
Copy file name to clipboardExpand all lines: packages/snip20/Readme.md
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,14 @@ You can create a HandleMsg variant and call the `to_cosmos_msg` function to gene
11
11
Or you can call the individual function for each Handle message to generate the appropriate callback CosmosMsg.
12
12
13
13
Example:
14
+
14
15
```ignore
15
-
let recipient = HumanAddr("ADDRESS_TO_TRANSFER_TO".to_string());
16
+
let recipient = "ADDRESS_TO_TRANSFER_TO".to_string();
16
17
let amount = Uint128(10000);
17
18
let padding = None;
18
19
let block_size = 256;
19
20
let callback_code_hash = "TOKEN_CONTRACT_CODE_HASH".to_string();
20
-
let contract_addr = HumanAddr("TOKEN_CONTRACT_ADDRESS".to_string());
21
+
let contract_addr = "TOKEN_CONTRACT_ADDRESS".to_string();
21
22
22
23
let cosmos_msg = transfer_msg(
23
24
recipient,
@@ -28,19 +29,17 @@ Example:
28
29
contract_addr,
29
30
)?;
30
31
31
-
Ok(HandleResponse {
32
-
messages: vec![cosmos_msg],
33
-
log: vec![],
34
-
data: None,
35
-
})
32
+
Ok(Response::new().add_message(cosmos_msg))
36
33
```
34
+
37
35
All you have to do to call a SNIP-20 Handle function is call the appropriate toolkit function, and place the resulting `CosmosMsg` in the `messages` Vec of the InitResponse or HandleResponse. In this example, we are transferring 10000 (in the lowest denomination of the token) to the recipient address. We are not using the `padding` field of the Transfer message, but instead, we are padding the entire message to blocks of 256 bytes.
38
36
39
37
You probably have also noticed that CreateViewingKey is not supported. This is because a contract can not see the viewing key that is returned because it has already finished executing by the time CreateViewingKey would be called. If a contract needs to have a viewing key, it must create its own sufficiently complex viewing key, and pass it as a parameter to SetViewingKey. You can see an example of creating a complex viewing key in the [Snip20 Reference Implementation](http://github.com/enigmampc/snip20-reference-impl). It is also highly recommended that you use the block_size padding option to mask the length of the viewing key your contract has generated.
40
38
41
39
## Queries
42
40
43
41
These are the types that SNIP20 tokens can return from queries
In this example, we are doing a Balance query for the specified address/key pair and storing the response in the balance variable, which is of the Balance type defined above. The query message is padded to blocks of 256 bytes.
@@ -11,14 +11,15 @@ You can create a HandleMsg variant and call the `to_cosmos_msg` function to gene
11
11
Or you can call the individual function for each Handle message to generate the appropriate callback CosmosMsg.
12
12
13
13
Example:
14
+
14
15
```ignore
15
-
let recipient = HumanAddr("ADDRESS_TO_TRANSFER_TO".to_string());
16
+
let recipient = "ADDRESS_TO_TRANSFER_TO".to_string();
16
17
let token_id = "TOKEN_ID".to_string();
17
18
let memo = Some("TRANSFER_MEMO".to_string());
18
19
let padding = None;
19
20
let block_size = 256;
20
21
let callback_code_hash = "TOKEN_CONTRACT_CODE_HASH".to_string();
21
-
let contract_addr = HumanAddr("TOKEN_CONTRACT_ADDRESS".to_string());
22
+
let contract_addr = "TOKEN_CONTRACT_ADDRESS".to_string();
22
23
23
24
let cosmos_msg = transfer_nft_msg(
24
25
recipient,
@@ -30,19 +31,17 @@ Example:
30
31
contract_addr,
31
32
)?;
32
33
33
-
Ok(HandleResponse {
34
-
messages: vec![cosmos_msg],
35
-
log: vec![],
36
-
data: None,
37
-
})
34
+
Ok(Response::new().add_message(cosmos_msg))
38
35
```
36
+
39
37
All you have to do to call a SNIP-721 Handle function is call the appropriate toolkit function, and place the resulting `CosmosMsg` in the `messages` Vec of the InitResponse or HandleResponse. In this example, we are transferring an NFT named "TOKEN_ID" to the recipient address. We are not using the `padding` field of the Transfer message, but instead, we are padding the entire message to blocks of 256 bytes.
40
38
41
39
You probably have also noticed that CreateViewingKey is not supported. This is because a contract can not see the viewing key that is returned because it has already finished executing by the time CreateViewingKey would be called. If a contract needs to have a viewing key, it must create its own sufficiently complex viewing key, and pass it as a parameter to SetViewingKey. You can see an example of creating a complex viewing key in the [Snip20 Reference Implementation](http://github.com/enigmampc/snip20-reference-impl). It is also highly recommended that you use the block_size padding option to mask the length of the viewing key your contract has generated.
42
40
43
41
## Queries
44
42
45
43
These are the types that the SNIP-721 toolkit queries can return
In this example, we are doing an NftDossier query on the token named "TOKEN_ID", supplying the address and viewing key of the querier, and storing the response in the nft_dossier variable, which is of the NftDossier type defined above. Because no `include_expired` was specified, the response defaults to only displaying approvals that have not expired, but approvals will only be displayed if the viewer is the owner of the token. The query message is padded to blocks of 256 bytes.
0 commit comments