Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 920-documentation-r…
Browse files Browse the repository at this point in the history
…endering
  • Loading branch information
ElliotFriend committed Jun 4, 2024
2 parents 5b12f6b + 9390f6c commit 6f74f95
Show file tree
Hide file tree
Showing 6 changed files with 1,031 additions and 839 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ A breaking change will get clearly marked in this log.
## Unreleased


## [v12.0.1](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.1)

- This is a re-tag of `v12.0.0-rc.3` with dependency updates and a single new feature.

### Added
- `rpc.server.simulateTransaction` now supports an optional `stateChanges?: LedgerEntryChange[]` field ([#963](https://github.com/stellar/js-stellar-sdk/pull/963)):
* If `Before` is omitted, it constitutes a creation, if `After` is omitted, it constitutes a deletions, note that `Before` and `After` cannot be be omitted at the same time. Each item follows this schema:

```typescript
interface LedgerEntryChange {
type: number;
key: xdr.LedgerKey;
before: xdr.LedgerEntry | null;
after: xdr.LedgerEntry | null;
}
```


## [v12.0.0-rc.3](https://github.com/stellar/js-stellar-sdk/compare/v11.3.0...v12.0.0-rc.3)

### Breaking Changes
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stellar/stellar-sdk",
"version": "12.0.0-rc.3",
"version": "12.0.1",
"description": "A library for working with the Stellar network, including communication with the Horizon and Soroban RPC servers.",
"keywords": [
"stellar"
Expand Down Expand Up @@ -92,26 +92,26 @@
]
},
"devDependencies": {
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.3",
"@babel/eslint-plugin": "^7.22.10",
"@babel/preset-env": "^7.24.3",
"@babel/preset-typescript": "^7.24.1",
"@babel/register": "^7.23.7",
"@babel/cli": "^7.24.6",
"@babel/core": "^7.24.6",
"@babel/eslint-plugin": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@babel/preset-typescript": "^7.24.6",
"@babel/register": "^7.24.6",
"@definitelytyped/dtslint": "^0.2.20",
"@istanbuljs/nyc-config-babel": "3.0.0",
"@stellar/tsconfig": "^1.0.2",
"@types/chai": "^4.3.14",
"@types/detect-node": "^2.0.0",
"@types/eventsource": "^1.1.12",
"@types/json-schema": "^7.0.15",
"@types/lodash": "^4.17.0",
"@types/lodash": "^4.17.4",
"@types/mocha": "^10.0.2",
"@types/node": "^20.11.30",
"@types/node": "^20.12.13",
"@types/randombytes": "^2.0.1",
"@types/sinon": "^17.0.2",
"@types/urijs": "^1.19.20",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/parser": "^7.11.0",
"ava": "^5.3.1",
"axios-mock-adapter": "^1.22.0",
"babel-loader": "^9.1.3",
Expand All @@ -128,11 +128,11 @@
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.2.4",
"eslint-plugin-jsdoc": "^48.2.7",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-import": "^0.0.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-webpack-plugin": "^4.1.0",
"eslint-webpack-plugin": "^4.2.0",
"ghooks": "^2.0.4",
"husky": "^9.0.11",
"jsdoc": "^4.0.2",
Expand All @@ -145,7 +145,7 @@
"karma-mocha": "^2.0.0",
"karma-sinon-chai": "^2.0.2",
"karma-webpack": "^5.0.1",
"lint-staged": "^15.2.2",
"lint-staged": "^15.2.5",
"lodash": "^4.17.21",
"minami": "^1.1.1",
"mocha": "^10.3.0",
Expand All @@ -163,8 +163,8 @@
"webpack-cli": "^5.0.1"
},
"dependencies": {
"@stellar/stellar-base": "^12.0.0-rc.1",
"axios": "^1.6.8",
"@stellar/stellar-base": "^12.0.0",
"axios": "^1.7.2",
"bignumber.js": "^9.1.2",
"eventsource": "^2.0.2",
"randombytes": "^2.1.0",
Expand Down
43 changes: 28 additions & 15 deletions src/rpc/api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { AssetType, Contract, SorobanDataBuilder, xdr } from '@stellar/stellar-base';
import { Contract, SorobanDataBuilder, xdr } from '@stellar/stellar-base';

/* tslint:disable-next-line:no-namespace */
export namespace Api {
export interface Balance {
asset_type: AssetType.credit4 | AssetType.credit12;
asset_code: string;
asset_issuer: string;
classic: string;
smart: string;
}

export interface Cost {
cpuInsns: string;
Expand Down Expand Up @@ -174,8 +167,21 @@ export namespace Api {
value: string;
}

export interface RequestAirdropResponse {
transaction_id: string;
interface RawLedgerEntryChange {
type: number;
/** This is LedgerKey in base64 */
key: string;
/** This is xdr.LedgerEntry in base64 */
before: string | null;
/** This is xdr.LedgerEntry in base64 */
after: string | null;
}

export interface LedgerEntryChange {
type: number;
key: xdr.LedgerKey;
before: xdr.LedgerEntry | null;
after: xdr.LedgerEntry | null;
}

export type SendTransactionStatus =
Expand Down Expand Up @@ -263,6 +269,9 @@ export namespace Api {

/** present only for invocation simulation */
result?: SimulateHostFunctionResult;

/** State Difference information */
stateChanges?: LedgerEntryChange[];
}

/** Includes details about why the simulation failed */
Expand Down Expand Up @@ -332,19 +341,23 @@ export namespace Api {
id: string;
latestLedger: number;
error?: string;
// this is an xdr.SorobanTransactionData in base64
/** This is an xdr.SorobanTransactionData in base64 */
transactionData?: string;
// these are xdr.DiagnosticEvents in base64
/** These are xdr.DiagnosticEvents in base64 */
events?: string[];
minResourceFee?: string;
// This will only contain a single element if present, because only a single
// invokeHostFunctionOperation is supported per transaction.
/** This will only contain a single element if present, because only a single
* invokeHostFunctionOperation is supported per transaction.
* */
results?: RawSimulateHostFunctionResult[];
cost?: Cost;
// present if succeeded but has expired ledger entries
/** Present if succeeded but has expired ledger entries */
restorePreamble?: {
minResourceFee: string;
transactionData: string;
};

/** State Difference information */
stateChanges?: RawLedgerEntryChange[];
}
}
14 changes: 13 additions & 1 deletion src/rpc/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,19 @@ function parseSuccessful(
: xdr.ScVal.scvVoid()
};
})[0]
})
}),

...(sim.stateChanges?.length ?? 0 > 0) && {
stateChanges: sim.stateChanges?.map((entryChange) => {
return {
type: entryChange.type,
key: xdr.LedgerKey.fromXDR(entryChange.key, 'base64'),
before: entryChange.before ? xdr.LedgerEntry.fromXDR(entryChange.before, 'base64') : null,
after: entryChange.after ? xdr.LedgerEntry.fromXDR(entryChange.after, 'base64') : null,
};
})
}

};

if (!sim.restorePreamble || sim.restorePreamble.transactionData === '') {
Expand Down
Loading

0 comments on commit 6f74f95

Please sign in to comment.