-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add SEP6 deposit and withdrawal (#77)
* add sep6 deposit and withdrawal * comment * make better response * remove wrapper type
- Loading branch information
Showing
3 changed files
with
257 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
import { Wallet } from "../src"; | ||
import axios from "axios"; | ||
|
||
let wallet; | ||
let anchor; | ||
let sep6; | ||
let accountKp; | ||
|
||
describe("SEP-6", () => { | ||
beforeAll(async () => { | ||
wallet = Wallet.TestNet(); | ||
anchor = wallet.anchor({ homeDomain: "testanchor.stellar.org" }); | ||
sep6 = anchor.sep6(); | ||
|
||
accountKp = wallet.stellar().account().createKeypair(); | ||
await axios.get( | ||
"https://friendbot.stellar.org/?addr=" + accountKp.publicKey, | ||
); | ||
}, 10000); | ||
it("should get anchor info", async () => { | ||
const wallet = Wallet.TestNet(); | ||
const anchor = wallet.anchor({ homeDomain: "testanchor.stellar.org" }); | ||
const sep6 = anchor.sep6(); | ||
const resp = await sep6.info(); | ||
expect(resp.deposit).toBeTruthy(); | ||
expect(resp.withdraw).toBeTruthy(); | ||
|
@@ -13,4 +26,71 @@ describe("SEP-6", () => { | |
expect(refreshed.deposit).toBeTruthy(); | ||
expect(refreshed.withdraw).toBeTruthy(); | ||
}); | ||
it("should deposit", async () => { | ||
const auth = await anchor.sep10(); | ||
const authToken = await auth.authenticate({ accountKp }); | ||
|
||
const sep12 = await anchor.sep12(authToken); | ||
|
||
// Make first call with missing KYC info | ||
let resp = await sep6.deposit({ | ||
authToken, | ||
params: { | ||
asset_code: "SRT", | ||
account: accountKp.publicKey, | ||
type: "bank_account", | ||
}, | ||
}); | ||
expect(resp.type).toBe("non_interactive_customer_info_needed"); | ||
|
||
// Add the missing KYC info | ||
await sep12.add({ | ||
sep9Info: { | ||
first_name: "john", | ||
last_name: "smith", | ||
email_address: "[email protected]", | ||
bank_number: "12345", | ||
bank_account_number: "12345", | ||
}, | ||
}); | ||
|
||
// Make deposit call again with all info uploaded | ||
resp = await sep6.deposit({ | ||
authToken, | ||
params: { | ||
asset_code: "SRT", | ||
account: accountKp.publicKey, | ||
type: "bank_account", | ||
}, | ||
}); | ||
expect(resp.id).toBeTruthy(); | ||
}); | ||
it("should withdraw", async () => { | ||
const auth = await anchor.sep10(); | ||
const authToken = await auth.authenticate({ accountKp }); | ||
|
||
const sep12 = await anchor.sep12(authToken); | ||
|
||
await sep12.add({ | ||
sep9Info: { | ||
first_name: "john", | ||
last_name: "smith", | ||
email_address: "[email protected]", | ||
bank_number: "12345", | ||
bank_account_number: "12345", | ||
}, | ||
}); | ||
|
||
const resp = await sep6.withdraw({ | ||
authToken, | ||
params: { | ||
asset_code: "SRT", | ||
account: accountKp.publicKey, | ||
type: "bank_account", | ||
dest: "123", | ||
dest_extra: "12345", | ||
}, | ||
}); | ||
expect(resp.id).toBeTruthy(); | ||
}); | ||
}); |