From 57f8f207304c501a1327341599e6c2ba73d930c7 Mon Sep 17 00:00:00 2001 From: !shan Date: Fri, 24 Nov 2023 18:22:17 +0100 Subject: [PATCH] Use address instead of public key (#9157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 Use address instead of public key --- .../src/chain_connector_plugin.ts | 8 ++++++-- .../lisk-framework-chain-connector-plugin/src/utils.ts | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/framework-plugins/lisk-framework-chain-connector-plugin/src/chain_connector_plugin.ts b/framework-plugins/lisk-framework-chain-connector-plugin/src/chain_connector_plugin.ts index 30576d1033..03d548f4c2 100644 --- a/framework-plugins/lisk-framework-chain-connector-plugin/src/chain_connector_plugin.ts +++ b/framework-plugins/lisk-framework-chain-connector-plugin/src/chain_connector_plugin.ts @@ -73,6 +73,7 @@ import { chainAccountDataJSONToObj, channelDataJSONToObj, getMainchainID, + getTokenIDLSK, proveResponseJSONToObj, } from './utils'; @@ -171,8 +172,11 @@ export class ChainConnectorPlugin extends BasePlugin 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')}`, }, ); diff --git a/framework-plugins/lisk-framework-chain-connector-plugin/src/utils.ts b/framework-plugins/lisk-framework-chain-connector-plugin/src/utils.ts index 780a4cdc07..39b17c450c 100644 --- a/framework-plugins/lisk-framework-chain-connector-plugin/src/utils.ts +++ b/framework-plugins/lisk-framework-chain-connector-plugin/src/utils.ts @@ -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'),