@okxweb3/coin-stellar
Version:
@okxweb3/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers
45 lines • 1.48 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contract = void 0;
const address_1 = require("./address");
const operation_1 = require("./operation");
const xdr_1 = __importDefault(require("./xdr"));
const strkey_1 = require("./strkey");
class Contract {
constructor(contractId) {
try {
this._id = strkey_1.StrKey.decodeContract(contractId);
}
catch (_) {
throw new Error(`Invalid contract ID: ${contractId}`);
}
}
contractId() {
return strkey_1.StrKey.encodeContract(this._id);
}
toString() {
return this.contractId();
}
address() {
return address_1.Address.contract(this._id);
}
call(method, ...params) {
return operation_1.Operation.invokeContractFunction({
contract: this.address().toString(),
function: method,
args: params
});
}
getFootprint() {
return xdr_1.default.LedgerKey.contractData(new xdr_1.default.LedgerKeyContractData({
contract: this.address().toScAddress(),
key: xdr_1.default.ScVal.scvLedgerKeyContractInstance(),
durability: xdr_1.default.ContractDataDurability.persistent()
}));
}
}
exports.Contract = Contract;
//# sourceMappingURL=contract.js.map