Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDR support for Auth Next #65

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Stellar-contract-spec.x
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum SCSpecType
SC_SPEC_TYPE_STATUS = 10,
SC_SPEC_TYPE_BYTES = 11,
SC_SPEC_TYPE_INVOKER = 12,
SC_SPEC_TYPE_ACCOUNT_ID = 13,
SC_SPEC_TYPE_ADDRESS = 13,

// Types with parameters.
SC_SPEC_TYPE_OPTION = 1000,
Expand Down Expand Up @@ -98,8 +98,7 @@ case SC_SPEC_TYPE_SYMBOL:
case SC_SPEC_TYPE_BITSET:
case SC_SPEC_TYPE_STATUS:
case SC_SPEC_TYPE_BYTES:
case SC_SPEC_TYPE_INVOKER:
case SC_SPEC_TYPE_ACCOUNT_ID:
case SC_SPEC_TYPE_ADDRESS:
void;
case SC_SPEC_TYPE_OPTION:
SCSpecTypeOption option;
Expand Down
23 changes: 20 additions & 3 deletions Stellar-contract.x
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ enum SCObjectType
SCO_I128 = 5,
SCO_BYTES = 6,
SCO_CONTRACT_CODE = 7,
SCO_ACCOUNT_ID = 8
SCO_ADDRESS = 8,
SCO_NONCE_KEY = 9

// TODO: add more
};
Expand Down Expand Up @@ -255,6 +256,20 @@ struct Int128Parts {
uint64 hi;
};

enum SCAddressType
{
SC_ADDRESS_TYPE_ACCOUNT = 0,
SC_ADDRESS_TYPE_CONTRACT = 1
};

union SCAddress switch (SCAddressType type)
{
case SC_ADDRESS_TYPE_ACCOUNT:
AccountID accountId;
case SC_ADDRESS_TYPE_CONTRACT:
Hash contractId;
};

union SCObject switch (SCObjectType type)
{
case SCO_VEC:
Expand All @@ -273,7 +288,9 @@ case SCO_BYTES:
opaque bin<SCVAL_LIMIT>;
case SCO_CONTRACT_CODE:
SCContractCode contractCode;
case SCO_ACCOUNT_ID:
AccountID accountID;
case SCO_ADDRESS:
SCAddress address;
case SCO_NONCE_KEY:
SCAddress nonceAddress;
dmkozh marked this conversation as resolved.
Show resolved Hide resolved
};
}
3 changes: 2 additions & 1 deletion Stellar-ledger-entries.x
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ enum EnvelopeType
ENVELOPE_TYPE_CONTRACT_ID_FROM_CONTRACT = 9,
ENVELOPE_TYPE_CONTRACT_ID_FROM_ASSET = 10,
ENVELOPE_TYPE_CONTRACT_ID_FROM_SOURCE_ACCOUNT = 11,
ENVELOPE_TYPE_CREATE_CONTRACT_ARGS = 12
ENVELOPE_TYPE_CREATE_CONTRACT_ARGS = 12,
ENVELOPE_TYPE_CONTRACT_AUTH = 13
};
}
32 changes: 31 additions & 1 deletion Stellar-transaction.x
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,36 @@ case HOST_FUNCTION_TYPE_INSTALL_CONTRACT_CODE:
InstallContractCodeArgs installContractCodeArgs;
};

struct AuthorizedInvocation
{
Hash contractID;
SCSymbol functionName;
SCVec args;
AuthorizedInvocation subInvocations<>;
dmkozh marked this conversation as resolved.
Show resolved Hide resolved
dmkozh marked this conversation as resolved.
Show resolved Hide resolved
};

struct AddressWithNonce
{
SCAddress address;
uint64 nonce;
};

struct ContractAuth
{
AddressWithNonce* addressWithNonce; // not present for invoker
AuthorizedInvocation rootInvocation;
SCVec signatureArgs;
};

struct InvokeHostFunctionOp
{
// The host function to invoke
HostFunction function;
// The footprint for this invocation
LedgerFootprint footprint;
// Per-address authorizations for this host fn
// Currently only supported for INVOKE_CONTRACT function
ContractAuth auth<>;
};

/* An operation is the lowest unit of work that a transaction does */
Expand Down Expand Up @@ -653,7 +677,13 @@ case ENVELOPE_TYPE_CREATE_CONTRACT_ARGS:
Hash networkID;
SCContractCode source;
uint256 salt;
} createContractArgs;
} createContractArgs;
case ENVELOPE_TYPE_CONTRACT_AUTH:
struct
{
Hash networkID;
AuthorizedInvocation invocation;
} contractAuth;
};

enum MemoType
Expand Down