Skip to content

Commit

Permalink
wip add submitXdrTransactionStellar
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonKozAllB committed Dec 4, 2023
1 parent d4638ac commit c774c7c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/srb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ import BalanceLineAsset = Horizon.BalanceLineAsset;
* Contains usefully Soroban methods
*/
export interface SrbUtils {
buildChangeTrustTx(limit: string, sender: string, tokenAddress: string): Promise<string>;
buildChangeTrustLineXdrTx(limit: string, sender: string, tokenAddress: string): Promise<string>;

getTrustLine(sender: string, tokenAddress: string): Promise<Horizon.BalanceLine | undefined>;

submitXdrTransactionStellar(xdrTx: string): Promise<Horizon.SubmitTransactionResponse>;
}

const FEE = 100;
Expand All @@ -28,7 +30,7 @@ const SEND_TRANSACTION_TIMEOUT = 180;
export class DefaultSrbUtils implements SrbUtils {
constructor(readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig, readonly params: AllbridgeCoreSdkOptions) {}

async buildChangeTrustTx(limit: string, sender: string, tokenAddress: string): Promise<string> {
async buildChangeTrustLineXdrTx(limit: string, sender: string, tokenAddress: string): Promise<string> {
const stellar = new StellarServer(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB_STLR));
const stellarAccount = await stellar.loadAccount(sender);
// stellarAccount.in
Expand Down Expand Up @@ -70,6 +72,12 @@ export class DefaultSrbUtils implements SrbUtils {
);
}

async submitXdrTransactionStellar(xdrTx: string): Promise<Horizon.SubmitTransactionResponse> {
const stellar = new StellarServer(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB_STLR));
const transaction = StellarTransactionBuilder.fromXDR(xdrTx, this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB_STLR));
return await stellar.submitTransaction(transaction);
}

private async getContract<T>(contract: new (args: ClassOptions) => T, address: string): Promise<T> {
const config: ClassOptions = {
contractId: address,
Expand Down

0 comments on commit c774c7c

Please sign in to comment.