Skip to content

Commit

Permalink
Develop (#339)
Browse files Browse the repository at this point in the history
* fix: avoid using substrate native name

* update: adjust RING/DOT ratio

* update: better error info

* update: sign prefix

* update: accuracy

* update: claims list
  • Loading branch information
aurexav authored Mar 13, 2020
1 parent b2b9adc commit b99c4b2
Show file tree
Hide file tree
Showing 10 changed files with 13,333 additions and 13,325 deletions.
4 changes: 2 additions & 2 deletions .maintain/types/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@
"_struct": "AddressT"
},

"Signature": {
"OtherSignature": {
"_enum": {
"Dot": "EcdsaSignature",
"Eth": "EcdsaSignature",
"Tron": "EcdsaSignature"
}
},

"Address": {
"OtherAddress": {
"_enum": {
"Dot": "EthereumAddress",
"Eth": "EthereumAddress",
Expand Down
12 changes: 6 additions & 6 deletions .maintain/types/types.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ title = "Darwinia Node Runtime Types"
EthereumAddress._struct = "AddressT"
TronAddress._struct = "AddressT"

Signature._enum.Dot = "EcdsaSignature"
Signature._enum.Eth = "EcdsaSignature"
Signature._enum.Tron = "EcdsaSignature"
OtherSignature._enum.Dot = "EcdsaSignature"
OtherSignature._enum.Eth = "EcdsaSignature"
OtherSignature._enum.Tron = "EcdsaSignature"

Address._enum.Dot = "EthereumAddress"
Address._enum.Eth = "EthereumAddress"
Address._enum.Tron = "TronAddress"
OtherAddress._enum.Dot = "EthereumAddress"
OtherAddress._enum.Eth = "EthereumAddress"
OtherAddress._enum.Tron = "TronAddress"

EcdsaSignature._struct = "[u8; 65]"
12 changes: 6 additions & 6 deletions .maintain/utility/format_claims_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ def append_format(origin: str, content: dict) -> str:
with open('genesis_sample.json') as f:
j = json.load(f)

n_j = '{ "eth": ['
n_j = '{ "dot": ['
n_j = append_format(n_j, j['dot'])
n_j = n_j[:-1] + '],'

n_j += '"eth": ['
n_j = append_format(n_j, j['eth'])
n_j = n_j[:-1] + '],'

n_j += '"tron": ['
n_j = append_format(n_j, j['tron'])
n_j = n_j[:-1] + '],'

n_j += '"dot": ['
n_j = append_format(n_j, j['dot'])
n_j = n_j[:-1] + ']}'

with open('claims_list.json', 'w+') as f:
with open('../../bin/node/cli/res/claims_list.json', 'w') as f:
f.write(n_j)

13,198 changes: 6,599 additions & 6,599 deletions .maintain/utility/genesis_sample.json

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions .maintain/utility/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"math/big"
"math/rand"
"net/http"
"strconv"
"strings"
"sync"
)
Expand Down Expand Up @@ -69,12 +70,12 @@ func main() {
read("data/bank.csv",
result.Eth,
func(s string) string { return s },
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(1, 18)) })
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(1, 9)) })

read("data/bank_tron.csv",
result.Tron,
func(s string) string { return s },
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(1, 18)) })
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(1, 9)) })

// Eth
read("data/eth.csv",
Expand All @@ -89,20 +90,20 @@ func main() {
balance = decimal.RequireFromString(sr[0]).Mul(decimal.RequireFromString(sr[1]))
}
}
return balance.Mul(decimal.New(1, 18))
return balance.Mul(decimal.New(1, 9))
})

// Tron
read("data/tron.csv",
result.Tron,
func(s string) string { return TrxBase58toHexAddress(s) },
func(f string) decimal.Decimal { return decimal.RequireFromString(f) })
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Div(decimal.New(1, 9)) })

// Dot
read("data/dot.csv",
result.Dot,
func(s string) string { return s },
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(50, 18)) })
func(f string) decimal.Decimal { return decimal.RequireFromString(f).Mul(decimal.New(50, 9)) })

// filter
var contracts []string
Expand Down Expand Up @@ -152,18 +153,24 @@ func main() {
}
wg.Wait()

var filter = func(r map[string]decimal.Decimal) {
for address := range r {
convert := make(map[string]map[string]uint64)
var filter = func(chain string, r map[string]decimal.Decimal) {
convert[chain] = make(map[string]uint64)
for address, balance := range r {
if StringInSlice(address, contracts) {
delete(r, address)
} else {
part := strings.Split(balance.String(), ".")
uint64Balance, _ := strconv.ParseUint(part[0], 10, 64)
convert[chain][address] = uint64Balance
}
}
}
filter(result.Eth)
filter(result.Tron)
filter(result.Dot)
filter("eth", result.Eth)
filter("tron", result.Tron)
filter("dot", result.Dot)

b, _ := json.Marshal(result)
b, _ := json.Marshal(convert)
fmt.Println(string(b))
}

Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/res/claims_list.json

Large diffs are not rendered by default.

13,332 changes: 6,666 additions & 6,666 deletions bin/node/cli/res/crab.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ fn load_claims_list(path: &str) -> pallet_claims::ClaimsList {
let mut path = path.to_owned();
if !Path::new(&path).is_file() {
let var = env::var("CLAIMS_LIST_PATH").expect(&format!(
"!!file NOT FOUND!! current path: {}, load from path: {}\n\
"\n\
!!file NOT FOUND!! current path: {}, load from path: {}\n\
!!CLAIMS_LIST_PATH var NOT FOUND!!\n\
At least one of them should be VALID",
At least one of them should be VALID\n",
env::current_dir().unwrap().display(),
path,
));
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl pallet_society::Trait for Runtime {
}

parameter_types! {
pub const Prefix: &'static [u8] = b"Pay RING to the Darwinia account:";
pub const Prefix: &'static [u8] = b"Pay RINGs to the Crab account:";
}
impl pallet_claims::Trait for Runtime {
type Event = Event;
Expand Down
Loading

0 comments on commit b99c4b2

Please sign in to comment.