forked from Stellar-split/split-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-health.ts
More file actions
32 lines (29 loc) · 1.1 KB
/
Copy pathtest-health.ts
File metadata and controls
32 lines (29 loc) · 1.1 KB
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
30
31
32
import { rpc, Contract, xdr } from "@stellar/stellar-sdk";
const server = new rpc.Server("https://soroban-testnet.stellar.org:443");
// We can create a valid contract ID
import { StrKey } from "@stellar/stellar-sdk";
const contractId = StrKey.encodeContract(Buffer.alloc(32));
async function run() {
console.log("Testing getAccount...");
try {
const acc = await server.getAccount(contractId);
console.log("getAccount success", acc);
} catch(e) {
console.log("getAccount err:", e.message);
}
console.log("Testing getLedgerEntries...");
try {
const { Address } = require("@stellar/stellar-sdk");
const ledgerKey = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({
contract: new Address(contractId).toScAddress(),
key: xdr.ScVal.scvLedgerKeyContractInstance(),
durability: xdr.ContractDataDurability.persistent(),
}));
const data = await server.getLedgerEntries(ledgerKey);
console.log("getLedgerEntries result:", data);
} catch(e) {
console.log("getLedgerEntries err:", e);
if (e.errors) console.log("Aggregate errors:", e.errors);
}
}
run();