Skip to content

Commit

Permalink
Use address instead of public key (#9157)
Browse files Browse the repository at this point in the history
🐛 Use address instead of public key
  • Loading branch information
ishantiw committed Nov 24, 2023
1 parent 9869bac commit 57f8f20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import {
chainAccountDataJSONToObj,
channelDataJSONToObj,
getMainchainID,
getTokenIDLSK,
proveResponseJSONToObj,
} from './utils';

Expand Down Expand Up @@ -171,8 +172,11 @@ export class ChainConnectorPlugin extends BasePlugin<ChainConnectorPluginConfig>
const userBalance = await this._receivingChainClient.invoke<{ exists: boolean }>(
'token_hasUserAccount',
{
address: address.getLisk32AddressFromAddress(tx.senderPublicKey as Buffer),
tokenID: `${this._receivingChainID.toString('hex')}00000000`,
address: address.getLisk32AddressFromAddress(
address.getAddressFromPublicKey(tx.senderPublicKey as Buffer),
),
// It is always LSK token
tokenID: `${getTokenIDLSK(this._receivingChainID).toString('hex')}`,
},
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export const getMainchainID = (chainID: Buffer): Buffer => {
return Buffer.concat([networkID, Buffer.alloc(CHAIN_ID_LENGTH - 1, 0)]);
};

export const getTokenIDLSK = (chainID: Buffer): Buffer => {
const networkID = chainID.slice(0, 1);
// 3 bytes for remaining chainID bytes
return Buffer.concat([networkID, Buffer.alloc(7, 0)]);
};

export const aggregateCommitToJSON = (aggregateCommit: AggregateCommit) => ({
height: aggregateCommit.height,
aggregationBits: aggregateCommit.aggregationBits.toString('hex'),
Expand Down

0 comments on commit 57f8f20

Please sign in to comment.