Skip to content

Commit

Permalink
fix(bindings-ts): latest RPC & stellar-sdk
Browse files Browse the repository at this point in the history
- update to `[email protected]`
- fetch expiration using new `getFootprint` logic
- improve `initialize.sh` to show network status
  - latest RPC returns better error messages
  - deal with these and parse `getHealth` response
  • Loading branch information
chadoh authored and willemneal committed Dec 14, 2023
1 parent c1fef8f commit 873ad47
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 351 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"@stellar/freighter-api": "1.7.1",
"buffer": "6.0.3",
"stellar-sdk": "11.0.0-beta.6"
"stellar-sdk": "11.0.0"
},
"scripts": {
"build": "node ./scripts/build.mjs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,15 @@ export class AssembledTransaction<T> {
}

getStorageExpiration = async () => {
const key = new Contract(this.options.contractId).getFootprint()[1]

const expirationKey = xdr.LedgerKey.expiration(
new xdr.LedgerKeyExpiration({ keyHash: hash(key.toXDR()) }),
const entryRes = await this.server.getLedgerEntries(
new Contract(this.options.contractId).getFootprint()
)

const entryRes = await this.server.getLedgerEntries(expirationKey)
if (!(entryRes.entries && entryRes.entries.length)) throw new Error('failed to get ledger entry')

return entryRes.entries[0].val.expiration().expirationLedgerSeq()
if (
!entryRes.entries ||
!entryRes.entries.length ||
!entryRes.entries[0].liveUntilLedgerSeq
) throw new Error('failed to get ledger entry')
return entryRes.entries[0].liveUntilLedgerSeq
}

/**
Expand Down
3 changes: 3 additions & 0 deletions cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ echo Network
echo " RPC: $SOROBAN_RPC_URL"
echo " Passphrase: \"$SOROBAN_NETWORK_PASSPHRASE\""

NETWORK_STATUS=$(curl -s -X POST "http://localhost:8000/soroban/rpc" -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 8675309, "method": "getHealth" }' | sed 's/.*"status":"\(.*\)".*/\1/') || { echo "Make sure you're running local RPC network on localhost:8000" && exit 1; }
echo " Status: $NETWORK_STATUS"

# Print command before executing, from https://stackoverflow.com/a/23342259/249801
# Discussion: https://github.com/stellar/soroban-tools/pull/1034#pullrequestreview-1690667116
exe() { echo"${@/eval/}" ; "$@" ; }
Expand Down
Loading

0 comments on commit 873ad47

Please sign in to comment.