Skip to content

Commit

Permalink
update template to expand objectLike values (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci authored Jan 30, 2023
1 parent 3b20760 commit 66b90c3
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 241 deletions.
226 changes: 64 additions & 162 deletions e2e/__snapshots__/dev.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -234,153 +234,79 @@ exports[`dev rpc > dryRun 1`] = `
"6",
],
"events": {
"0": {
"event": {
"data": {
"amount": [
"2,429,299",
"1,821,974",
],
},
},
},
"1": {
"event": {
"data": {
"amount": [
"2,429,299",
"1,821,974",
],
},
},
},
"2": {
"event": {
"data": {
"amount": [
"44,234,035",
"33,175,527",
],
"0": [
{
"event": {
"data": {
"amount": "1,821,974",
"currencyId": {
"Token": "AUSD",
},
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b0a",
"method": "Deposited",
"section": "tokens",
},
"phase": "Initialization",
"topics": [],
},
},
"3": {
"event": {
"data": {
"amount": [
"365,959,263",
"274,469,453",
],
],
"1": [
{
"event": {
"data": {
"amount": "1,821,974",
"currencyId": {
"Token": "AUSD",
},
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b00",
"method": "Endowed",
"section": "tokens",
},
"phase": "Initialization",
"topics": [],
},
},
"4": {
"event": {
"data": {
"amount": [
"1,000,000,000,000",
0,
0,
],
"currencyId": [
{
"Token": "TAI",
},
0,
0,
],
"dispatchInfo": [
{
"class": "Mandatory",
"paysFee": "Yes",
"weight": "158,080,000",
],
"2": [
{
"event": {
"data": {
"amount": "33,175,527",
"currencyId": {
"Token": "AUSD",
},
],
"from": [
"5EYCAe5fiQJsoMt16QywpBQwyn5cgfkXFFJApwwKPXFoF2h7",
0,
0,
],
"to": [
"5EYCAe5fiQJsnzYGdTNgiw719xk2hhoFczYFMNqwMx6JDf7h",
0,
0,
],
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b0a",
"method": "Deposited",
"section": "tokens",
},
"index": [
"0x0b02",
"0x0000",
],
"method": [
"Transfer",
"ExtrinsicSuccess",
],
"section": [
"tokens",
"system",
],
"phase": "Initialization",
"topics": [],
},
"phase": [
"Initialization",
{
"ApplyExtrinsic": "0",
},
],
},
"5": {
"event": {
"data": {
"amount": [
"1,000,000,000,000",
0,
0,
],
"currencyId": [
{
"Token": "TAI",
},
0,
0,
],
"dispatchInfo": [
{
"class": "Mandatory",
"paysFee": "Yes",
"weight": "0",
],
"3": [
{
"event": {
"data": {
"amount": "274,469,453",
"currencyId": {
"Token": "AUSD",
},
],
"from": [
"5EYCAe5fiQJsoMt16QywpBQwyn5cgfkXFFJApwwKPXFoF2h7",
0,
0,
],
"to": [
"5EYCAe5fiQJsnzYGdTNgiw719xk2hhoFczYFMNqwMx6JDf7h",
0,
0,
],
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b0a",
"method": "Deposited",
"section": "tokens",
},
"index": [
"0x0c00",
"0x0000",
],
"method": [
"Transferred",
"ExtrinsicSuccess",
],
"section": [
"currencies",
"system",
],
"phase": "Initialization",
"topics": [],
},
"phase": [
"Initialization",
{
"ApplyExtrinsic": "1",
},
],
},
"_6": [
],
"4": [
{
"event": {
"data": {
Expand All @@ -399,10 +325,8 @@ exports[`dev rpc > dryRun 1`] = `
},
"topics": [],
},
0,
0,
],
"_7": [
"5": [
{
"event": {
"data": {
Expand All @@ -421,28 +345,6 @@ exports[`dev rpc > dryRun 1`] = `
},
"topics": [],
},
0,
0,
],
"_8": [
{
"event": {
"data": {
"amount": "412,622,597",
"currencyId": {
"Token": "AUSD",
},
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b08",
"method": "Withdrawn",
"section": "tokens",
},
"phase": "Finalization",
"topics": [],
},
0,
0,
],
"_t": "a",
},
Expand Down
6 changes: 5 additions & 1 deletion src/utils/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,9 @@ export const decodeStorageDiff = async (block: Block, diff: [HexString, HexStrin
_.merge(oldState, await decodeKeyValue(block, key, (await block.get(key)) as any))
_.merge(newState, await decodeKeyValue(block, key, value))
}
return [oldState, newState, diffPatcher.diff(oldState, newState)]
const oldStateWithoutEvents = _.cloneDeep(oldState)
if (oldStateWithoutEvents['system']?.['events']) {
oldStateWithoutEvents['system']['events'] = []
}
return [oldState, newState, diffPatcher.diff(oldStateWithoutEvents, newState)]
}
Loading

0 comments on commit 66b90c3

Please sign in to comment.