diff --git a/airdrop/getter.gno b/airdrop/getter.gno index 137a6d9..f4c2491 100644 --- a/airdrop/getter.gno +++ b/airdrop/getter.gno @@ -117,6 +117,20 @@ func GetClaimStatus(jsonStr string, claimID uint64) string { } // AirdropToJSON converts an Airdrop struct to a JSON string. +// +// Example: +// +// { +// "config": { +// "refundable_timestamp": "1234567890", +// "refund_to": "g1234567890abcdefghijklmnop" +// }, +// "address": "g1234567890abcdefghijklmnop", +// "claimed_bitmap": { // ref: getter_test.gno/TestAirdropToJSONAndCreateAirdropFromJSON +// "0": "101", +// "1": "1101", +// }, +// } func AirdropToJSON(a *Airdrop) string { node := json.ObjectNode("", nil) @@ -166,7 +180,7 @@ func createAirdropFromJSON(jsonStr string) *Airdrop { configNode := node.MustKey("config") timestamp := configNode.MustKey("refundable_timestamp").MustString() - refundableTimestamp, err := parseUint(timestamp, 10, 64) + refundableTimestamp, err := strconv.Atoi(timestamp) if err != nil { panic(err) } @@ -180,7 +194,7 @@ func createAirdropFromJSON(jsonStr string) *Airdrop { claimedBitmap := make(map[uint64]uint64) claimedBitmapNode.ObjectEach(func(key string, value *json.Node) { - index, err := parseUint(key, 10, 64) + index, err := strconv.Atoi(key) if err != nil { panic(err) } @@ -188,12 +202,12 @@ func createAirdropFromJSON(jsonStr string) *Airdrop { if err != nil { panic(err) } - claimedBitmap[index] = bitmap + claimedBitmap[uint64(index)] = bitmap }) return &Airdrop{ config: Config{ - RefundableTimestamp: refundableTimestamp, + RefundableTimestamp: uint64(refundableTimestamp), RefundTo: refundTo, }, address: address,