Skip to content

Commit

Permalink
Merge pull request #12 from abuiles/credit-account
Browse files Browse the repository at this point in the history
Add credit mutation.
  • Loading branch information
abuiles committed Jul 10, 2018
2 parents 06c7104 + 3319abb commit 59261ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,28 @@ const resolvers = {
} catch (e) {
console.log(`failure ${e}`)

throw e
}
},
async credit(_, { amount, username }, context: Context, info) {
const user = await context.db.query.user({
where: {
username: username
}
})

try {
const { hash } = await payment(
// keypair for issuing account - no bueno
Keypair.fromSecret('SBYZ5NEJ34Y3FTKADVBO3Y76U6VLTREJSW4MXYCVMUBTL2K3V4Y644UX'),
user.stellarAccount,
amount
)

return { id: hash }
} catch (e) {
console.log(`failure ${e}`)

throw e
}
}
Expand Down
1 change: 1 addition & 0 deletions src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ type Query {
type Mutation {
signup(username: String!): User!
payment(amount: String!, senderUsername: String!, recipientUsername: String!, memo: String): Transaction
credit(amount: String!, username: String!): Transaction
}

0 comments on commit 59261ee

Please sign in to comment.