Skip to content

Commit

Permalink
Drop back XDR commit to the actually-built Core version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed May 8, 2023
1 parent b150214 commit 2d0df39
Show file tree
Hide file tree
Showing 8 changed files with 524 additions and 84 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/tmp/
/dist/
/config/dist/
/lib/
/coverage/
/jsdoc/
.DS_Store
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ XDR_FILES_CURR= \
Stellar-types.x
XDR_FILES_LOCAL_CURR=$(addprefix xdr/curr/,$(XDR_FILES_CURR))

XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/next
XDR_BASE_URL_NEXT=https://github.com/stellar/stellar-xdr/raw/2f16687fdf6f4bcfb56805e2035f69997f4b34c4
XDR_BASE_LOCAL_NEXT=xdr/next
XDR_FILES_NEXT= \
Stellar-SCP.x \
Expand Down
11 changes: 6 additions & 5 deletions src/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export class Contract {
});
}


/**
* Returns the read-only footprint entry necessary for any invocations to this
* contract, for convenience when adding it to your transaction's overall
Expand All @@ -79,9 +78,11 @@ export class Contract {
getFootprint() {
const contractId = Buffer.from(this._id, 'hex');

return xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({
contractId,
key: xdr.ScVal.scvLedgerKeyContractExecutable(),
}));
return xdr.LedgerKey.contractData(
new xdr.LedgerKeyContractData({
contractId,
key: xdr.ScVal.scvLedgerKeyContractExecutable()
})
);
}
}
192 changes: 162 additions & 30 deletions src/generated/next_generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -2545,6 +2545,75 @@ var types = XDR.config((xdr) => {
["ext", xdr.lookup("TransactionHistoryResultEntryExt")],
]);

// === xdr source ============================================================
//
// struct TransactionResultPairV2
// {
// Hash transactionHash;
// Hash hashOfMetaHashes; // hash of hashes in TransactionMetaV3
// // TransactionResult is in the meta
// };
//
// ===========================================================================
xdr.struct("TransactionResultPairV2", [
["transactionHash", xdr.lookup("Hash")],
["hashOfMetaHashes", xdr.lookup("Hash")],
]);

// === xdr source ============================================================
//
// struct TransactionResultSetV2
// {
// TransactionResultPairV2 results<>;
// };
//
// ===========================================================================
xdr.struct("TransactionResultSetV2", [
[
"results",
xdr.varArray(xdr.lookup("TransactionResultPairV2"), 2147483647),
],
]);

// === xdr source ============================================================
//
// union switch (int v)
// {
// case 0:
// void;
// }
//
// ===========================================================================
xdr.union("TransactionHistoryResultEntryV2Ext", {
switchOn: xdr.int(),
switchName: "v",
switches: [[0, xdr.void()]],
arms: {},
});

// === xdr source ============================================================
//
// struct TransactionHistoryResultEntryV2
// {
// uint32 ledgerSeq;
// TransactionResultSetV2 txResultSet;
//
// // reserved for future use
// union switch (int v)
// {
// case 0:
// void;
// }
// ext;
// };
//
// ===========================================================================
xdr.struct("TransactionHistoryResultEntryV2", [
["ledgerSeq", xdr.lookup("Uint32")],
["txResultSet", xdr.lookup("TransactionResultSetV2")],
["ext", xdr.lookup("TransactionHistoryResultEntryV2Ext")],
]);

// === xdr source ============================================================
//
// union switch (int v)
Expand Down Expand Up @@ -2829,6 +2898,30 @@ var types = XDR.config((xdr) => {
["event", xdr.lookup("ContractEvent")],
]);

// === xdr source ============================================================
//
// struct OperationDiagnosticEvents
// {
// DiagnosticEvent events<>;
// };
//
// ===========================================================================
xdr.struct("OperationDiagnosticEvents", [
["events", xdr.varArray(xdr.lookup("DiagnosticEvent"), 2147483647)],
]);

// === xdr source ============================================================
//
// struct OperationEvents
// {
// ContractEvent events<>;
// };
//
// ===========================================================================
xdr.struct("OperationEvents", [
["events", xdr.varArray(xdr.lookup("ContractEvent"), 2147483647)],
]);

// === xdr source ============================================================
//
// struct TransactionMetaV3
Expand All @@ -2838,49 +2931,33 @@ var types = XDR.config((xdr) => {
// OperationMeta operations<>; // meta for each operation
// LedgerEntryChanges txChangesAfter; // tx level changes after operations are
// // applied if any
// ContractEvent events<>; // custom events populated by the
// // contracts themselves.
// SCVal returnValues<MAX_OPS_PER_TX>; // return values of each invocation.
// OperationEvents events<>; // custom events populated by the
// // contracts themselves. One list per operation.
// TransactionResult txResult;
//
// // Diagnostics events that are not hashed.
// Hash hashes[3]; // stores sha256(txChangesBefore, operations, txChangesAfter),
// // sha256(events), and sha256(txResult)
//
// // Diagnostics events that are not hashed. One list per operation.
// // This will contain all contract and diagnostic events. Even ones
// // that were emitted in a failed contract call.
// DiagnosticEvent diagnosticEvents<>;
// OperationDiagnosticEvents diagnosticEvents<>;
// };
//
// ===========================================================================
xdr.struct("TransactionMetaV3", [
["txChangesBefore", xdr.lookup("LedgerEntryChanges")],
["operations", xdr.varArray(xdr.lookup("OperationMeta"), 2147483647)],
["txChangesAfter", xdr.lookup("LedgerEntryChanges")],
["events", xdr.varArray(xdr.lookup("ContractEvent"), 2147483647)],
[
"returnValues",
xdr.varArray(xdr.lookup("ScVal"), xdr.lookup("MAX_OPS_PER_TX")),
],
["events", xdr.varArray(xdr.lookup("OperationEvents"), 2147483647)],
["txResult", xdr.lookup("TransactionResult")],
["hashes", xdr.array(xdr.lookup("Hash"), 3)],
[
"diagnosticEvents",
xdr.varArray(xdr.lookup("DiagnosticEvent"), 2147483647),
xdr.varArray(xdr.lookup("OperationDiagnosticEvents"), 2147483647),
],
]);

// === xdr source ============================================================
//
// struct InvokeHostFunctionSuccessPreImage
// {
// SCVal returnValues<MAX_OPS_PER_TX>;
// ContractEvent events<>;
// };
//
// ===========================================================================
xdr.struct("InvokeHostFunctionSuccessPreImage", [
[
"returnValues",
xdr.varArray(xdr.lookup("ScVal"), xdr.lookup("MAX_OPS_PER_TX")),
],
["events", xdr.varArray(xdr.lookup("ContractEvent"), 2147483647)],
]);

// === xdr source ============================================================
//
// union TransactionMeta switch (int v)
Expand Down Expand Up @@ -2929,6 +3006,22 @@ var types = XDR.config((xdr) => {
["txApplyProcessing", xdr.lookup("TransactionMeta")],
]);

// === xdr source ============================================================
//
// struct TransactionResultMetaV2
// {
// TransactionResultPairV2 result;
// LedgerEntryChanges feeProcessing;
// TransactionMeta txApplyProcessing;
// };
//
// ===========================================================================
xdr.struct("TransactionResultMetaV2", [
["result", xdr.lookup("TransactionResultPairV2")],
["feeProcessing", xdr.lookup("LedgerEntryChanges")],
["txApplyProcessing", xdr.lookup("TransactionMeta")],
]);

// === xdr source ============================================================
//
// struct UpgradeEntryMeta
Expand Down Expand Up @@ -3013,6 +3106,41 @@ var types = XDR.config((xdr) => {
["scpInfo", xdr.varArray(xdr.lookup("ScpHistoryEntry"), 2147483647)],
]);

// === xdr source ============================================================
//
// struct LedgerCloseMetaV2
// {
// LedgerHeaderHistoryEntry ledgerHeader;
//
// GeneralizedTransactionSet txSet;
//
// // NB: transactions are sorted in apply order here
// // fees for all transactions are processed first
// // followed by applying transactions
// TransactionResultMetaV2 txProcessing<>;
//
// // upgrades are applied last
// UpgradeEntryMeta upgradesProcessing<>;
//
// // other misc information attached to the ledger close
// SCPHistoryEntry scpInfo<>;
// };
//
// ===========================================================================
xdr.struct("LedgerCloseMetaV2", [
["ledgerHeader", xdr.lookup("LedgerHeaderHistoryEntry")],
["txSet", xdr.lookup("GeneralizedTransactionSet")],
[
"txProcessing",
xdr.varArray(xdr.lookup("TransactionResultMetaV2"), 2147483647),
],
[
"upgradesProcessing",
xdr.varArray(xdr.lookup("UpgradeEntryMeta"), 2147483647),
],
["scpInfo", xdr.varArray(xdr.lookup("ScpHistoryEntry"), 2147483647)],
]);

// === xdr source ============================================================
//
// union LedgerCloseMeta switch (int v)
Expand All @@ -3021,6 +3149,8 @@ var types = XDR.config((xdr) => {
// LedgerCloseMetaV0 v0;
// case 1:
// LedgerCloseMetaV1 v1;
// case 2:
// LedgerCloseMetaV2 v2;
// };
//
// ===========================================================================
Expand All @@ -3030,10 +3160,12 @@ var types = XDR.config((xdr) => {
switches: [
[0, "v0"],
[1, "v1"],
[2, "v2"],
],
arms: {
v0: xdr.lookup("LedgerCloseMetaV0"),
v1: xdr.lookup("LedgerCloseMetaV1"),
v2: xdr.lookup("LedgerCloseMetaV2"),
},
});

Expand Down Expand Up @@ -7146,7 +7278,7 @@ var types = XDR.config((xdr) => {
// union InvokeHostFunctionResult switch (InvokeHostFunctionResultCode code)
// {
// case INVOKE_HOST_FUNCTION_SUCCESS:
// Hash success; // sha256(InvokeHostFunctionSuccessPreImage)
// SCVal success<MAX_OPS_PER_TX>;
// case INVOKE_HOST_FUNCTION_MALFORMED:
// case INVOKE_HOST_FUNCTION_TRAPPED:
// case INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED:
Expand All @@ -7164,7 +7296,7 @@ var types = XDR.config((xdr) => {
["invokeHostFunctionResourceLimitExceeded", xdr.void()],
],
arms: {
success: xdr.lookup("Hash"),
success: xdr.varArray(xdr.lookup("ScVal"), xdr.lookup("MAX_OPS_PER_TX")),
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/transaction_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TransactionBase {
const requiresContractSignatures = (this.operations || []).some(
(op) =>
op.type === 'invokeHostFunction' &&
op.functions.some(fn => fn.auth().some((a) => a.addressWithNonce()))
op.functions.some((fn) => fn.auth().some((a) => a.addressWithNonce()))
);
if (requiresContractSignatures) {
throw new Error(
Expand Down
Loading

0 comments on commit 2d0df39

Please sign in to comment.