-
-
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
feat: add listAccountTransactions
method
#41
base: main
Are you sure you want to change the base?
Conversation
4798162
to
9424622
Compare
c77bdf0
to
59e0736
Compare
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@metamask/utils@9.2.1 |
/** | ||
* Next cursor to iterate over the results. | ||
*/ | ||
next: exactOptional(string()), |
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.
I wonder if we should optional(nullable(string()))
here...
I was thinking of this example
const keyring = ...;
const pagination = {
limit: 10,
next: null, // No cursor yet
};
do {
const page = await keyring.listAccountTransactions(accountId, pagination);
// Do something with `page.transactions`...
pagination.next = page.next;
} while (page.next);
I think we cannot write this code here, because of the exactOptional
, right?
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 type was supposed to be used in the request, not the response:
listAccountTransactions(id, {limit: 10});
// or
listAccountTransactions(id, {limit: 10, next: '<cursor_token>'});
But now that you mentioned this case, I think we can do the change you mentioned and repurpose it to be used both ways 🤔 WDYT?
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.
Well... I really liked the exactOptional
initially yes, but I'm worried about it being hard to use, so I believe we could just allow null
in this case yes.
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
00b9d6f
to
ee4b6c9
Compare
Co-authored-by: Charly Chevalier <charly.chevalier@consensys.net>
a1fc8eb
to
ffb1c3a
Compare
* }, | ||
* ``` | ||
*/ | ||
const AmountStruct = object({ |
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.
TODO: Rename to AssetAmountStruct
/** | ||
* Total transaction fee. | ||
*/ | ||
fee: AmountStruct, |
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.
TODO: Discuss if it should be an array.
This method was originally part of the Chain API, but we decided to migrate it to the Keyring API since it's close related to accounts.
Also, it will allow to list the trasactions for a given account ID instead of address, which make it simpler to get the balances for Bitcoin accounts, for example.
Closes: https://github.com/MetaMask/accounts-planning/issues/460
Closes: https://github.com/MetaMask/accounts-planning/issues/453
Replaces: MetaMask/keyring-api#322