Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Merge token accounts #64

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

WIP: Merge token accounts #64

wants to merge 10 commits into from

Conversation

mocolicious
Copy link
Member

No description provided.

}

var dest = existingAccounts[0].key;
List<Instruction> instructions = List.empty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty list is not growable by default. Just declare using <Instruction>[], as Dart recommendation.

https://api.dart.dev/stable/2.14.4/dart-core/List/List.empty.html

instructions.add(MemoProgramBase64EncodedMemo.fromBytes((memo as KinBinaryMemo).encode()).instruction!);
}

instructions.add(createAssocAccount.instruction!);
Copy link
Contributor

@gmpassos gmpassos Nov 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you are adding to another growable list.

).instruction!);

dest = createAssocAccount.addr;
signers.add(signer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding to a not growable list.


var dest = existingAccounts[0].key;
List<Instruction> instructions = List.empty();
List<PrivateKey> signers = List.empty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue here. Just use <PrivateKey>[] to declare the list. Is the most portable and efficient way, since Dart will choose the most efficient implementation for the platform and allow more optimizations.

}
}

existing:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not declare a loop label if there's not a loop inside a loop.

import 'dart:typed_data';

import 'package:crypto/crypto.dart';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unecessary import

AssociatedTokenProgramCreateAssociatedTokenAccount(
this.subsidizer, this.wallet, this.mint);

late final addr = (AssociatedTokenProgram().getAssociatedAccount(wallet, mint) as PublicKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of ( and )


Instruction? _instruction;

Instruction? get instruction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the ??= operator

Instruction? _instruction;

Instruction? get instruction {
if(_instruction == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are not returning the _instruction.

Use the ??= operator


return new KinServiceResponse(KinServiceResponseType.ok, publicKeys);
return new KinServiceResponse(KinServiceResponseType.ok, publicKeys.map((e) => KinTokenAccountInfo(PublicKey(e.accountId.toString()), KinAmount.fromInt(e.balance.toInt()), PublicKey(e.closeAuthority.toString()))).toList());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate in 2 lines. Too many things in the same statement.

Copy link
Member Author

@mocolicious mocolicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finished changes

@mocolicious
Copy link
Member Author

Review complete, pending testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple token accounts created for wallet, whilst not being able to transact from any other token account.
2 participants