-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
var dest = existingAccounts[0].key; | ||
List<Instruction> instructions = List.empty(); |
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 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!); |
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.
Here you are adding to another growable list.
).instruction!); | ||
|
||
dest = createAssocAccount.addr; | ||
signers.add(signer); |
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.
Adding to a not growable list.
|
||
var dest = existingAccounts[0].key; | ||
List<Instruction> instructions = List.empty(); | ||
List<PrivateKey> signers = List.empty(); |
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.
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: |
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.
Do not declare a loop label if there's not a loop inside a loop.
import 'dart:typed_data'; | ||
|
||
import 'package:crypto/crypto.dart'; |
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.
Unecessary import
AssociatedTokenProgramCreateAssociatedTokenAccount( | ||
this.subsidizer, this.wallet, this.mint); | ||
|
||
late final addr = (AssociatedTokenProgram().getAssociatedAccount(wallet, mint) as PublicKey); |
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.
No need of (
and )
|
||
Instruction? _instruction; | ||
|
||
Instruction? get instruction { |
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.
use the ??=
operator
Instruction? _instruction; | ||
|
||
Instruction? get instruction { | ||
if(_instruction == null) { |
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.
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()); |
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.
separate in 2 lines. Too many things in the same statement.
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.
finished changes
Review complete, pending testing |
No description provided.