-
Notifications
You must be signed in to change notification settings - Fork 458
Update token module and transfer command - Closes #7117 and #7118 #7138
Update token module and transfer command - Closes #7117 and #7118 #7138
Conversation
5630234
to
c2b90ff
Compare
@@ -231,4 +264,31 @@ export class TokenAPI extends BaseAPI { | |||
return prev; | |||
}, BigInt(0)); | |||
} | |||
|
|||
public async isNative(apiContext: ImmutableAPIContext, tokenID: TokenID): Promise<boolean> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added isNative
for fee module to check if chainID is native or not
|
||
import { CHAIN_ID_ALIAS_NATIVE, CHAIN_ID_LENGTH, TOKEN_ID_LENGTH } from './constants'; | ||
import { TokenID } from './types'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
util functions for handling store key and token ID format
}, | ||
required: ['address'], | ||
required: ['address', 'tokenID'], | ||
}; | ||
|
||
export const transferParamsSchema = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated schema, and add restriction on schema. This is used in the validation
@@ -59,7 +67,11 @@ export class TokenModule extends BaseModule { | |||
const genesisStore = codec.decode<GenesisTokenStore>(genesisTokenStoreSchema, assetBytes); | |||
const userStore = context.getStore(this.id, STORE_PREFIX_USER); | |||
for (const userData of genesisStore.userSubstore) { | |||
await userStore.setWithSchema(userData.address, userData, userStoreSchema); | |||
await userStore.setWithSchema( | |||
getUserStoreKey(userData.address, userData.tokenID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Temporally update the genesis block handling. Proper implementation will be done in #7119
@@ -52,26 +63,38 @@ export class TokenAPI extends BaseAPI { | |||
apiContext: APIContext, | |||
senderAddress: Buffer, | |||
recipientAddress: Buffer, | |||
_tokenID: TokenID, | |||
tokenID: TokenID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this transfer
function is the main change. Other API will be properly implemented in #7122
import { BaseCommand } from '../../base_command'; | ||
import { CommandExecuteContext } from '../../../node/state_machine'; | ||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this command is the main file updated
ec09f11
to
0f68d97
Compare
51bd1db
to
3110c5f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main changes LGTM besides the open point with Maxime
What was the problem?
This PR resolves #7117 and #7118
How was it solved?
How was it tested?