Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 57f8f20

Browse files
authored
Use address instead of public key (#9157)
🐛 Use address instead of public key
1 parent 9869bac commit 57f8f20

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

framework-plugins/lisk-framework-chain-connector-plugin/src/chain_connector_plugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
chainAccountDataJSONToObj,
7474
channelDataJSONToObj,
7575
getMainchainID,
76+
getTokenIDLSK,
7677
proveResponseJSONToObj,
7778
} from './utils';
7879

@@ -171,8 +172,11 @@ export class ChainConnectorPlugin extends BasePlugin<ChainConnectorPluginConfig>
171172
const userBalance = await this._receivingChainClient.invoke<{ exists: boolean }>(
172173
'token_hasUserAccount',
173174
{
174-
address: address.getLisk32AddressFromAddress(tx.senderPublicKey as Buffer),
175-
tokenID: `${this._receivingChainID.toString('hex')}00000000`,
175+
address: address.getLisk32AddressFromAddress(
176+
address.getAddressFromPublicKey(tx.senderPublicKey as Buffer),
177+
),
178+
// It is always LSK token
179+
tokenID: `${getTokenIDLSK(this._receivingChainID).toString('hex')}`,
176180
},
177181
);
178182

framework-plugins/lisk-framework-chain-connector-plugin/src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export const getMainchainID = (chainID: Buffer): Buffer => {
5050
return Buffer.concat([networkID, Buffer.alloc(CHAIN_ID_LENGTH - 1, 0)]);
5151
};
5252

53+
export const getTokenIDLSK = (chainID: Buffer): Buffer => {
54+
const networkID = chainID.slice(0, 1);
55+
// 3 bytes for remaining chainID bytes
56+
return Buffer.concat([networkID, Buffer.alloc(7, 0)]);
57+
};
58+
5359
export const aggregateCommitToJSON = (aggregateCommit: AggregateCommit) => ({
5460
height: aggregateCommit.height,
5561
aggregationBits: aggregateCommit.aggregationBits.toString('hex'),

0 commit comments

Comments
 (0)