difftreelog
ci give money to alice on fork
in: master
2 files changed
.docker/forkless-config/fork.jsonnetdiffbeforeafterboth--- a/.docker/forkless-config/fork.jsonnet
+++ b/.docker/forkless-config/fork.jsonnet
@@ -8,6 +8,8 @@
if sourceRaw[key] != null
};
+local typeNames = (import './typeNames.jsonnet')(sourceChain);
+
local
auraKeys = [
// AuraExt.Authorities, we don't have aura pallet enabled for some reason, to refer using cql api
@@ -45,6 +47,7 @@
if std.all(std.map(function(prefix) !std.startsWith(key, prefix), unwantedPrefixes))
};
+
local originalRaw = rawSpec.genesis.raw.top;
local outSpec = rawSpec {
genesis+: {
@@ -52,8 +55,42 @@
top: cleanupRaw(raw) {
[key]: originalRaw[key]
for key in wantedKeys
+ if std.objectHas(originalRaw, key)
},
},
},
};
-outSpec
+
+local
+ aliceAccount = sourceChain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d']),
+ totalIssuance = sourceChain.Balances._encodeKey.TotalIssuance([]),
+ unique = cql.calc(["10", "18", "**"]),
+ Munique = cql.calc([unique, "10", "6", "**", "*"]),
+;
+
+outSpec {
+ genesis+: {
+ raw+: {
+ top+: {
+ [totalIssuance]: cql.calc([
+ Munique,
+ if std.objectHas(super, totalIssuance) then sourceChain._decode(typeNames.u128, super[totalIssuance]) else '0',
+ if std.objectHas(super, aliceAccount) then sourceChain._decode(typeNames.AccountInfo, super[aliceAccount]).data.free else '0',
+ '-', '+',
+ ]),
+ [aliceAccount]: sourceChain._encode(typeNames.AccountInfo, {
+ nonce: 0,
+ consumers: 3,
+ providers: 1,
+ sufficients: 0,
+ data: {
+ free: Munique,
+ reserved: "0",
+ misc_frozen: "0",
+ fee_frozen: "0",
+ },
+ },)
+ },
+ },
+ },
+}
.docker/forkless-config/typeNames.jsonnetdiffbeforeafterboth1function(chain)2local3 typeName(id) = local4 ty = chain._meta.types.types[id],5 name = if std.objectHas(ty.type, "path") then6 std.join('::', ty.type.path)7 else if std.objectHas(ty.type.def, "primitive") then ty.type.def.primitive8 else if std.objectHas(ty.type.def, "tuple") then "(" + std.join(', ', std.map(typeName, ty.type.def.tuple)) + ")"9 else if std.objectHas(ty.type.def, "sequence") then "Vec<" + typeName(ty.type.def.sequence.type) + ">"10 else if std.objectHas(ty.type.def, "array") then "[" + typeName(ty.type.def.array.type) + "; " + ty.type.def.array.len + "]"11 else if std.objectHas(ty.type.def, "compact") then "Compact<" + typeName(ty.type.def.compact.type) + ">"12 else error "Can't generate useable name for " + ty.type,13 generics = if std.objectHas(ty.type, "params") then14 '<' + std.join(', ', std.map(function(p) if p.type == null then 'Spec#'+id else typeName(p.type), ty.type.params)) + '>'15 else ''16 ; name + generics,17 shortenPrefix(obj, prefix, short) = {18 [short]: obj[field]19 for field in std.objectFields(obj)20 // There should be at most one element with this prefix21 if std.startsWith(field, prefix)22 },23;2425local typesRaw = {26 [typeName(id)]: id27 for id in std.range(0, std.length(chain._meta.types.types)-1)28};2930local types = typesRaw + shortenPrefix(typesRaw, 'frame_system::AccountInfo<', 'AccountInfo');3132types33// local34// ;3536// local encoded = chain._encode(types['AccountInfo'], {37// nonce: 0,38// consumers: 3,39// providers: 1,40// sufficients: 0,41// data: {42// free: Munique,43// reserved: "0",44// misc_frozen: "0",45// fee_frozen: "0",46// },47// });4849// local systemAccount = chain._decode(types['AccountInfo'], encoded);5051// chain.System._encodeKey.Account(['0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'])