Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/payments-engine/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ var StellarService = class {
/**
* Sends funds from the operational storage to a destination address
*/
async sendFunds(destinationAddress, amount) {
async sendFunds(destinationAddress, amount, assetCode, assetIssuer) {
try {
const sourceAccount = await this.server.loadAccount(this.sourceKeypair.publicKey());
const asset = assetCode && assetIssuer ? new StellarSdk.Asset(assetCode, assetIssuer) : StellarSdk.Asset.native();
const transaction = new StellarSdk.TransactionBuilder(sourceAccount, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: process.env.STELLAR_NETWORK_URL?.includes("public") ? StellarSdk.Networks.PUBLIC : StellarSdk.Networks.TESTNET
}).addOperation(
StellarSdk.Operation.payment({
destination: destinationAddress,
asset: StellarSdk.Asset.native(),
asset,
amount
})
).setTimeout(30).build();
Expand Down
5 changes: 3 additions & 2 deletions packages/payments-engine/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ var StellarService = class {
/**
* Sends funds from the operational storage to a destination address
*/
async sendFunds(destinationAddress, amount) {
async sendFunds(destinationAddress, amount, assetCode, assetIssuer) {
try {
const sourceAccount = await this.server.loadAccount(this.sourceKeypair.publicKey());
const asset = assetCode && assetIssuer ? new StellarSdk.Asset(assetCode, assetIssuer) : StellarSdk.Asset.native();
const transaction = new StellarSdk.TransactionBuilder(sourceAccount, {
fee: StellarSdk.BASE_FEE,
networkPassphrase: process.env.STELLAR_NETWORK_URL?.includes("public") ? StellarSdk.Networks.PUBLIC : StellarSdk.Networks.TESTNET
}).addOperation(
StellarSdk.Operation.payment({
destination: destinationAddress,
asset: StellarSdk.Asset.native(),
asset,
amount
})
).setTimeout(30).build();
Expand Down
2 changes: 2 additions & 0 deletions packages/payments-engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface PaymentIntentType {
id: string;
amount: number;
currency: string;
assetCode?: string;
assetIssuer?: string;
status: 'pending' | 'completed' | 'failed';
createdAt: Date;
updatedAt: Date;
Expand Down
13 changes: 11 additions & 2 deletions packages/payments-engine/src/stellar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ export class StellarService {
/**
* Sends funds from the operational storage to a destination address
*/
async sendFunds(destinationAddress: string, amount: string): Promise<string> {
async sendFunds(
destinationAddress: string,
amount: string,
assetCode?: string,
assetIssuer?: string,
): Promise<string> {
try {
const sourceAccount = await this.server.loadAccount(this.sourceKeypair.publicKey());
const asset =
assetCode && assetIssuer
? new StellarSdk.Asset(assetCode, assetIssuer)
: StellarSdk.Asset.native();

const transaction = new StellarSdk.TransactionBuilder(sourceAccount, {
fee: StellarSdk.BASE_FEE,
Expand All @@ -37,7 +46,7 @@ export class StellarService {
.addOperation(
StellarSdk.Operation.payment({
destination: destinationAddress,
asset: StellarSdk.Asset.native(),
asset,
amount: amount,
}),
)
Expand Down
Loading