Skip to content

Commit

Permalink
populate username attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
oXtxNt9U committed Dec 4, 2024
1 parent 9427e5c commit bca945d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/api-sync/source/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ export class Sync implements Contracts.ApiSync.Service {
const attributes = {
...validatorAttributes(account.address),
...(account.unvote ? { unvote: account.unvote } : account.vote ? { vote: account.vote } : {}),
...(account.usernameResigned
? { usernameResigned: account.usernameResigned }
: account.username
? { username: account.username }
: {}),
};

return [
Expand Down Expand Up @@ -420,6 +425,13 @@ export class Sync implements Contracts.ApiSync.Service {
ELSE COALESCE(EXCLUDED.attributes->>'vote', "Wallet".attributes->>'vote')
END,
-- if any username is present, it will overwrite the previous username
'username',
CASE
WHEN (EXCLUDED.attributes->>'usernameResigned')::boolean IS TRUE THEN NULL
ELSE COALESCE(EXCLUDED.attributes->>'username', "Wallet".attributes->>'username')
END,
'validatorPublicKey',
COALESCE(EXCLUDED.attributes->>'validatorPublicKey', "Wallet".attributes->>'validatorPublicKey'),
'validatorResigned',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export class GenesisBlockGenerator extends Generator {
account: genesisWalletAddress,
deployerAccount: this.#deployerAddress,
initialSupply: Utils.BigNumber.make(options.premine).toBigInt(),
validatorContract: ethers.getCreateAddress({ from: genesisWalletAddress, nonce: 0 }),
validatorContract: ethers.getCreateAddress({ from: genesisWalletAddress, nonce: 1 }),
usernameContract: ethers.getCreateAddress({ from: genesisWalletAddress, nonce: 3 }),
};
await this.evm.initializeGenesis(genesisInfo);

Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/source/contracts/evm/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface GenesisInfo {
readonly account: string;
readonly deployerAccount: string;
readonly validatorContract: string;
readonly usernameContract: string;
readonly initialSupply: bigint;
}

Expand Down Expand Up @@ -52,6 +53,8 @@ export interface AccountUpdate {

readonly vote?: string;
readonly unvote?: string;
readonly username?: string;
readonly usernameResigned: boolean;
}

export interface AccountUpdateContext {
Expand Down
1 change: 1 addition & 0 deletions packages/evm-consensus/source/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class Deployer {
deployerAccount: this.deployerAddress,
initialSupply: Utils.BigNumber.make(genesisBlock.block.totalAmount).toBigInt(),
validatorContract: ethers.getCreateAddress({ from: this.deployerAddress, nonce: 1 }), // PROXY Uses nonce 1
usernameContract: ethers.getCreateAddress({ from: this.deployerAddress, nonce: 3 }), // PROXY Uses nonce 3
};

await this.evm.initializeGenesis(genesisInfo);
Expand Down
1 change: 1 addition & 0 deletions packages/evm-service/source/instances/evm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class EvmInstance implements Contracts.Evm.Instance {
deployerAccount: commit.deployerAccount,
initialSupply: commit.initialSupply,
validatorContract: commit.validatorContract,
usernameContract: commit.usernameContract,
});
}

Expand Down

0 comments on commit bca945d

Please sign in to comment.