-
Notifications
You must be signed in to change notification settings - Fork 7
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
add SEP6 deposit and withdrawal #77
Conversation
src/walletSdk/Anchor/Sep6.ts
Outdated
return resp.data; | ||
} catch (e) { | ||
if (e.response?.data?.type === "non_interactive_customer_info_needed") { | ||
throw new Sep12MissingInfoError(e.response?.data?.fields); |
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 don't think it's an error. It's expected behavior in the flow. I think we should have different types of the Sep6Response which wallets must handle accordingly
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.
BTW you can find flow diagrams for SEP-6 here
https://github.com/stellar/java-stellar-anchor-sdk/tree/develop/docs/diagrams/sep6
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.
good point, how about this? fb25d34
also I realized those resposnes can be for deposit or withdrawal so i added a helper flow function similar to sep24
* @throws {Sep6DepositDeniedError} If the deposit is still being processed or not accepted. | ||
* @throws {Error} If an unexpected error occurs during the deposit operation. | ||
*/ | ||
async deposit({ |
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.
What about exchange endoints, are they out of scope?
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.
ya I thought that's what this ticket is for right?
src/walletSdk/Anchor/Sep6.ts
Outdated
} catch (e) { | ||
if (e.response?.data?.type === "non_interactive_customer_info_needed") { | ||
return { | ||
type: Sep6ResponseType.MISSING_KYC, |
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 we need to explicitly provide type to all this responses?
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.
it makes it a bit clearer for the user to handle with typescript
eg. w/ a type in the response:
const resp = deposit(...)
if (resp.type === Sep6ResponseType.MISSING_KYC) {
console.log((resp.data as Types.Sep6MissingKYC).fields);
}
otherwise have to do something like:
if ("fields" in resp) {
console.log((resp.data as Types.Sep6MissingKYC).fields);
}
I'm not tied to it, I can remove it. Then the response will look like this:
export interface Sep6DepositResponse {
data: Sep6DepositSuccess | Sep6MissingKYC | Sep6Pending;
}
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.
after thinking about it more I think you're right removing the type field and using a Union type is best, and is the more standard typescript way of handling
* add type aliases, and make sep24 example use env vars (#66) * add type aliases * make example use env vars * Account setup and recovery using SEP-30 (#65) * Add AccountRecover class * Add Recovery class * Add builderExtra param * Fix importing * Swallow 404 error on registerRecoveryServerSigners function * Remove todo comment * Use plural * Add basic testing * increase timeout * Move private functions to the bottom * Make AccountRecover abstract * Rename type to WalletRecoveryServers * add Customer / SEP-12 code (#71) * add type aliases * make example use env vars * finish tests * add types * cleanup * comment update * use getCustomer * jsdoc * for binary data * clean up * cleanup * use sep9BinaryInfo * cleanup * add gha and linting (#72) * add type aliases * make example use env vars * finish tests * add types * cleanup * add gha * clean up all files * add prettier lint * sep12 stuff linting * cleanup * move to devdeps * add jsdocs to all major functions (#73) * add type aliases * make example use env vars * finish tests * add types * cleanup * add gha * clean up all files * add prettier lint * sep12 stuff linting * cleanup * add for all classes * more comments * more fixes * more changes * cleanup * small fixes to Recovery code (#75) * small fixes * fix path payment test * add sep6 get info (#76) * add SEP6 deposit and withdrawal (#77) * add sep6 deposit and withdrawal * comment * make better response * remove wrapper type * add exchange endpoints (#78) * adding recovery integration tests (#74) * first cut * try workflow * run daemon * print logs * restart on failure * try this * try * try * try * try * cross fingers * fix * works hopefully * fix * add back * cleanup * image versions and readme * add watcher and polling to sep6 (#79) * upgrade stellar-sdk to v11.0.0-beta.6 (#80) * add authToken class (#81) * add authToken class * make account optional * cleanup * remove un-needed account * adding some helper methods (#82) * account merge and premade assets (#83) * add sep38 info, price, and prices (#84) * sep38 getinfo * add prices info, cleanup * move authToken to optional arg * add jsdoc * throw if both buy and sell amount given * add sep38 quote (#85) * sep38 getinfo * add prices info, cleanup * first cut * move authToken to optional arg * cleanup * add jsdoc * throw if both buy and sell amount given * make context type right (#86) * fix test * bumping package version --------- Co-authored-by: Alec Charbonneau <[email protected]> Co-authored-by: Cássio Marcos Goulart <[email protected]>
ticket