forked from Prompt-Hash-Stellar/prompt-hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnativeAssetClient.ts
More file actions
29 lines (26 loc) · 789 Bytes
/
Copy pathnativeAssetClient.ts
File metadata and controls
29 lines (26 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { scValArg, prepareContractCall, submitPreparedTransaction, type StellarNetworkConfig, type WalletTransactionSigner } from "./tx";
export interface NativeAssetConfig extends StellarNetworkConfig {
nativeAssetContractId: string;
}
export async function approveNativeAssetSpend(
config: NativeAssetConfig,
signer: WalletTransactionSigner,
owner: string,
spender: string,
amount: bigint,
expirationLedger: number,
) {
const prepared = await prepareContractCall(
config,
owner,
config.nativeAssetContractId,
"approve",
[
scValArg(owner, "address"),
scValArg(spender, "address"),
scValArg(amount, "i128"),
scValArg(expirationLedger, "u32"),
],
);
return submitPreparedTransaction(config, prepared, signer, owner);
}