Skip to content

feat(sdk-coin-icp): integrate ic0 library for account balance retrieval #6118

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mohd-kashif
Copy link
Contributor

TIcket: WIN-5479

@mohd-kashif mohd-kashif self-assigned this May 13, 2025
@mohd-kashif mohd-kashif force-pushed the WIN-5479 branch 2 times, most recently from 3904437 to 482a65d Compare May 13, 2025 14:04
@mohd-kashif mohd-kashif marked this pull request as ready for review May 13, 2025 15:55
@mohd-kashif mohd-kashif requested review from a team as code owners May 13, 2025 15:55
@mohd-kashif mohd-kashif force-pushed the WIN-5479 branch 2 times, most recently from 9bc1c79 to b2a5acf Compare May 14, 2025 08:21
@@ -268,8 +234,7 @@ export class Icp extends BaseCoin {
const decodedResponse = utils.cborDecode(response.data) as PublicNodeSubmitResponse;

if (decodedResponse.status === 'replied') {
const txnId = this.extractTransactionId(decodedResponse);
return { txId: txnId };
return {};
Copy link
Contributor

Choose a reason for hiding this comment

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

why returning empty object here? We should know what recovery txn hash we generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

broadcastTransaction() returns BaseBroadcastTransactionResult which have the txId but we dont have a way to get the txId from the response and we cant change the signature of broadcastTransaction() as its a inherited function
so I have returned a {} response and set the txId in the recover() as we have the builder object in the recover()

Copy link
Contributor

Choose a reason for hiding this comment

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

cool, we need to just handle it properly from the caller then.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add a comment to explain/why status == 'replied' is treated as a success response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Comment on lines 277 to 283
const agent = this.createAgent();
const ic = replica(agent, { local: true });

const ledger = ic(Principal.fromUint8Array(LEDGER_CANISTER_ID).toText());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these steps will be common for any rpc call that we directly make to public fullnode for this canister. For eg v3/submit api and balance fetch api. If yes, then please make a generic function and pass params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

v3/submit and balance fetch has different process to make the request therefore they have different methods
maybe other methods like feeEstimates or derive might have same process as the balance fetch

Copy link
Contributor

Choose a reason for hiding this comment

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

as discussed over call, please add the todo ticket to move the ic-agent calls to a separate file as a follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@@ -185,6 +185,14 @@ export interface RecoveryOptions {
memo?: number | BigInt;
}

export interface RecoveryTransaction {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a standard that other coins also follow for recovery ? As far as I remember they only return txId.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i checked XRP, TRX and TON coins, they are having similar return fields

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the need here is only for id and tx. As discussed offline, pls make the necessary change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is only id and tx

@mohd-kashif mohd-kashif force-pushed the WIN-5479 branch 2 times, most recently from dec516d to c4cfed7 Compare May 15, 2025 08:02
@mohd-kashif mohd-kashif force-pushed the WIN-5479 branch 4 times, most recently from 9370a10 to 9d8607b Compare May 16, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants