git.delta.rocks / unique-network / refs/commits / 7f428c48e2d7

difftreelog

ci give money to alice on fork

Yaroslav Bolyukin2022-08-18parent: #b38709b.patch.diff
in: master

2 files changed

modified.docker/forkless-config/fork.jsonnetdiffbeforeafterboth
8 if sourceRaw[key] != null8 if sourceRaw[key] != null
9};9};
1010
11local typeNames = (import './typeNames.jsonnet')(sourceChain);
12
11local13local
12auraKeys = [14auraKeys = [
13 // AuraExt.Authorities, we don't have aura pallet enabled for some reason, to refer using cql api15 // AuraExt.Authorities, we don't have aura pallet enabled for some reason, to refer using cql api
45 if std.all(std.map(function(prefix) !std.startsWith(key, prefix), unwantedPrefixes))47 if std.all(std.map(function(prefix) !std.startsWith(key, prefix), unwantedPrefixes))
46};48};
4749
50
48local originalRaw = rawSpec.genesis.raw.top;51local originalRaw = rawSpec.genesis.raw.top;
49local outSpec = rawSpec {52local outSpec = rawSpec {
50 genesis+: {53 genesis+: {
51 raw+: {54 raw+: {
52 top: cleanupRaw(raw) {55 top: cleanupRaw(raw) {
53 [key]: originalRaw[key]56 [key]: originalRaw[key]
54 for key in wantedKeys57 for key in wantedKeys
58 if std.objectHas(originalRaw, key)
55 },59 },
56 },60 },
57 },61 },
58};62};
63
64local
65 aliceAccount = sourceChain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),
66 totalIssuance = sourceChain.Balances._encodeKey.TotalIssuance([]),
67 unique = cql.calc(["10", "18", "**"]),
68 Munique = cql.calc([unique, "10", "6", "**", "*"]),
69;
70
59outSpec71outSpec {
72 genesis+: {
73 raw+: {
74 top+: {
75 [totalIssuance]: cql.calc([
76 Munique,
77 if std.objectHas(super, totalIssuance) then sourceChain._decode(typeNames.u128, super[totalIssuance]) else '0',
78 if std.objectHas(super, aliceAccount) then sourceChain._decode(typeNames.AccountInfo, super[aliceAccount]).data.free else '0',
79 '-', '+',
80 ]),
81 [aliceAccount]: sourceChain._encode(typeNames.AccountInfo, {
82 nonce: 0,
83 consumers: 3,
84 providers: 1,
85 sufficients: 0,
86 data: {
87 free: Munique,
88 reserved: "0",
89 misc_frozen: "0",
90 fee_frozen: "0",
91 },
92 },)
93 },
94 },
95 },
96}
6097
added.docker/forkless-config/typeNames.jsonnetdiffbeforeafterboth
--- /dev/null
+++ b/.docker/forkless-config/typeNames.jsonnet
@@ -0,0 +1,51 @@
+function(chain)
+local
+	typeName(id) = local
+		ty = chain._meta.types.types[id],
+		name = if std.objectHas(ty.type, "path") then
+			std.join('::', ty.type.path)
+		else if std.objectHas(ty.type.def, "primitive") then ty.type.def.primitive
+		else if std.objectHas(ty.type.def, "tuple") then "(" + std.join(', ', std.map(typeName, ty.type.def.tuple)) + ")"
+		else if std.objectHas(ty.type.def, "sequence") then "Vec<" + typeName(ty.type.def.sequence.type) + ">"
+		else if std.objectHas(ty.type.def, "array") then "[" + typeName(ty.type.def.array.type) + "; " + ty.type.def.array.len + "]"
+		else if std.objectHas(ty.type.def, "compact") then "Compact<" + typeName(ty.type.def.compact.type) + ">"
+		else error "Can't generate useable name for " + ty.type,
+		generics = if std.objectHas(ty.type, "params") then
+			'<' + std.join(', ', std.map(function(p) if p.type == null then 'Spec#'+id else typeName(p.type), ty.type.params)) + '>'
+		else ''
+	; name + generics,
+	shortenPrefix(obj, prefix, short) = {
+		[short]: obj[field]
+		for field in std.objectFields(obj)
+		// There should be at most one element with this prefix
+		if std.startsWith(field, prefix)
+	},
+;
+
+local typesRaw = {
+	[typeName(id)]: id
+	for id in std.range(0, std.length(chain._meta.types.types)-1)
+};
+
+local types = typesRaw + shortenPrefix(typesRaw, 'frame_system::AccountInfo<', 'AccountInfo');
+
+types
+// local
+// ;
+
+// local encoded = chain._encode(types['AccountInfo'], {
+// 	nonce: 0,
+// 	consumers: 3,
+// 	providers: 1,
+// 	sufficients: 0,
+// 	data: {
+// 		free: Munique,
+// 		reserved: "0",
+// 		misc_frozen: "0",
+// 		fee_frozen: "0",
+// 	},
+// });
+
+// local systemAccount = chain._decode(types['AccountInfo'], encoded);
+
+// chain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'])