@xcapit/shelter-sdk
Version:
SDK for Shelter smart contracts on Stellar
30 lines (29 loc) • 1.11 kB
JavaScript
import { Keypair } from "shelter-sdk";
import { Shelter } from "../shelter/shelter";
import { Rpc } from "../rpc/rpc";
import { Transfer } from "../transfer/transfer";
import { FakeSAC } from "../fake-sac/fake-sac";
import { Transaction } from "../transaction/transaction";
export class Aid {
_recipient;
_sponsor;
_token;
_shelter;
_rpc;
constructor(_recipient, _sponsor, _token, _shelter, _rpc) {
this._recipient = _recipient;
this._sponsor = _sponsor;
this._token = _token;
this._shelter = _shelter;
this._rpc = _rpc;
}
async bound(amount, expiration) {
await this._shelter.boundAid(this._recipient.rawPublicKey(), this._token.options.contractId, amount, expiration);
}
async unbound() {
await this._shelter.unboundAid(this._recipient.rawPublicKey(), this._token.options.contractId);
}
async transfer(to, amount, pass) {
await new Transaction(await new Transfer(this._shelter.id(), to, amount, this._token).value(pass), this._sponsor, this._rpc, "Transfer Aid Error", true).result();
}
}