@xcapit/shelter-sdk
Version:
SDK for Shelter smart contracts on Stellar
39 lines (38 loc) • 1.28 kB
JavaScript
import { Client, Keypair } from "shelter-sdk";
import { Transaction } from "../transaction/transaction";
export class DeployedShelter {
_steward;
_rpc;
_client;
constructor(_steward, _rpc, _client) {
this._steward = _steward;
this._rpc = _rpc;
this._client = _client;
}
async stewardId() {
return (await this._client.steward()).result;
}
async boundAid(recipient, token, amount, expiration) {
await new Transaction(await this._client.bound_aid({
recipient,
token,
amount,
expiration,
}), this._steward, this._rpc, 'Bound Aid Error').result();
}
id() {
return this._client.options.contractId;
}
async aidOf(recipient, token) {
return (await this._client.aid_of({ recipient, token })).result.amount;
}
async guard() {
await new Transaction(await this._client.guard(), this._steward, this._rpc, 'Guard Gate Error').result();
}
async open() {
await new Transaction(await this._client.open(), this._steward, this._rpc, 'Open Gate Error').result();
}
async seal() {
await new Transaction(await this._client.seal(), this._steward, this._rpc, 'Seal Gate Error').result();
}
}