Skip to content

Commit

Permalink
Encode WASM address
Browse files Browse the repository at this point in the history
  • Loading branch information
bobo-k2 committed Oct 25, 2023
1 parent 125511a commit d54759b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/services/GiantSquid/CallParser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { injectable } from 'inversify';
import { encodeAddress } from '@polkadot/util-crypto';
import { UserEvent } from '../../models/DappStaking';
import { DappStakingCallData } from './ResponseData';
import { CallNameMapping } from './CallNameMapping';
Expand Down Expand Up @@ -46,7 +47,7 @@ export class NominationTransferParser extends CallParser implements ICallParser
public parse(call: DappStakingCallData): UserEvent {
const result = super.parse(call);

//There are two different argStr layouts for this event
// There are two different argStr layouts for this event
// nomination_transfer [
// 'Evm',
// '0xa782e40252e557d9e270650243546dbcd879d995',
Expand All @@ -63,8 +64,14 @@ export class NominationTransferParser extends CallParser implements ICallParser
// ]

// Check if 3rd arg is an address or not.
const isAddress = call.argsStr[2] !== 'Evm' && call.argsStr[2] !== 'Wasm';
result.contractAddress = isAddress ? call.argsStr[2] : call.argsStr[3];
const isWasm = call.argsStr[2] === 'Wasm';
const isAddress = call.argsStr[2] !== 'Evm' && !isWasm;
let nominatedContractAddress = isAddress ? call.argsStr[2] : call.argsStr[3];
if (isWasm) {
nominatedContractAddress = encodeAddress(nominatedContractAddress, 5);
}

result.contractAddress = nominatedContractAddress;
result.amount = isAddress ? call.argsStr[3] : call.argsStr[4];

return result;
Expand Down

0 comments on commit d54759b

Please sign in to comment.