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

Update token module and transfer command - Closes #7117 and #7118 #7138

Merged

Conversation

shuse2
Copy link
Collaborator

@shuse2 shuse2 commented Apr 25, 2022

What was the problem?

This PR resolves #7117 and #7118

How was it solved?

  • Add schema and constants and transfer command as described in LIP

How was it tested?

  • All unit/integration tests should pass
  • Update transfer command unit test

@shuse2 shuse2 requested review from ishantiw and mitsuaki-u April 25, 2022 15:08
@shuse2 shuse2 self-assigned this Apr 25, 2022
@shuse2 shuse2 changed the title Update constants and schema for token module - Closes #7117 Update constants and schema for token module - Closes #7117 and #7118 Apr 25, 2022
This was linked to issues Apr 25, 2022
@shuse2 shuse2 changed the title Update constants and schema for token module - Closes #7117 and #7118 Update token module and transfer command - Closes #7117 and #7118 Apr 25, 2022
@shuse2 shuse2 force-pushed the 7117-update_token_module branch from 5630234 to c2b90ff Compare April 26, 2022 10:01
@@ -231,4 +264,31 @@ export class TokenAPI extends BaseAPI {
return prev;
}, BigInt(0));
}

public async isNative(apiContext: ImmutableAPIContext, tokenID: TokenID): Promise<boolean> {
Copy link
Collaborator Author

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';

Copy link
Collaborator Author

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 = {
Copy link
Collaborator Author

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),
Copy link
Collaborator Author

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,
Copy link
Collaborator Author

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 {
Copy link
Collaborator Author

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

@shuse2 shuse2 force-pushed the 7117-update_token_module branch from ec09f11 to 0f68d97 Compare April 27, 2022 09:31
framework/src/modules/token/api.ts Show resolved Hide resolved
framework/src/modules/token/api.ts Outdated Show resolved Hide resolved
framework/src/modules/token/api.ts Outdated Show resolved Hide resolved
framework/src/modules/token/api.ts Show resolved Hide resolved
@shuse2 shuse2 force-pushed the 7117-update_token_module branch from 51bd1db to 3110c5f Compare April 28, 2022 20:37
@milenagojkovic milenagojkovic linked an issue Apr 29, 2022 that may be closed by this pull request
@shuse2 shuse2 removed a link to an issue Apr 29, 2022
@shuse2 shuse2 requested a review from MaximeGagnebin May 2, 2022 13:54
Copy link
Contributor

@mitsuaki-u mitsuaki-u left a 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

@shuse2 shuse2 requested a review from mitsuaki-u May 6, 2022 07:49
@shuse2 shuse2 merged commit 99778a3 into feature/6916-introduce_fungible_token_module May 6, 2022
@shuse2 shuse2 deleted the 7117-update_token_module branch May 6, 2022 10:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update token transfer command Update token module definition
3 participants