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

Allow trust after creating a trustline. #9

merged 1 commit into from Jul 9, 2018
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+34 −3
Diff settings


Just for now

Copy path View file
@@ -3,6 +3,7 @@ import { importSchema } from 'graphql-import'
import { Prisma } from './generated/prisma'
import {
} from './utils'
@@ -60,9 +61,9 @@ const resolvers = {
app. Use something like AWS lambda, or a separate system to
provision the Stellar account.

await createAccountInLedger(keypair.publicKey())
await createTrustline(keypair)
await allowTrust(keypair.publicKey())

return user
Copy path View file
@@ -26,8 +26,6 @@ export async function createAccountInLedger(newAccount) {

// Never put values like the an account seed in code.
const provisionerKeyPair = Keypair.fromSecret('SA72TGXRHE26WC5G5MTNURFUFBHZHTIQKF5AQWRXJMJGZUF4XY6HFWJ4')
const issuerKeyPair = Keypair.fromSecret('SBYZ5NEJ34Y3FTKADVBO3Y76U6VLTREJSW4MXYCVMUBTL2K3V4Y644UX')

const provisioner = await stellarServer.loadAccount(provisionerKeyPair.publicKey())

console.log('creating account in ledger', newAccount)
@@ -73,3 +71,35 @@ export async function createTrustline(accountKeypair) {
console.log('create trustline failed.', e)

export async function allowTrust(trustor) {
const stellarServer = new Server('');

try {
// Never store secrets in code! Use something like KMS and put
// this somewhere were few people can access it.
const issuingKeys = Keypair.fromSecret('SBYZ5NEJ34Y3FTKADVBO3Y76U6VLTREJSW4MXYCVMUBTL2K3V4Y644UX')
const issuingAccount = await stellarServer.loadAccount(issuingKeys.publicKey())

const transaction = new TransactionBuilder(issuingAccount)
assetCode: AnchorXUSD.code,
authorize: true


const result = await stellarServer.submitTransaction(transaction)

console.log('trust allowed', result)

return result
} catch (e) {
console.log('allow trust failed', e)
ProTip! Use n and p to navigate between commits in a pull request.