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

feat: add support for Protocol 14 #367

Merged
merged 8 commits into from
Oct 2, 2020
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
181 changes: 167 additions & 14 deletions .xdr/Stellar-ledger-entries.x
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ enum LedgerEntryType
ACCOUNT = 0,
TRUSTLINE = 1,
OFFER = 2,
DATA = 3
DATA = 3,
CLAIMABLE_BALANCE = 4
};

struct Signer
Expand All @@ -104,6 +105,39 @@ enum AccountFlags
// mask for all valid flags
const MASK_ACCOUNT_FLAGS = 0x7;

// maximum number of signers
const MAX_SIGNERS = 20;

typedef AccountID* SponsorshipDescriptor;

struct AccountEntryExtensionV2
{
uint32 numSponsored;
uint32 numSponsoring;
SponsorshipDescriptor signerSponsoringIDs<MAX_SIGNERS>;

union switch (int v)
{
case 0:
void;
}
ext;
};

struct AccountEntryExtensionV1
{
Liabilities liabilities;

union switch (int v)
{
case 0:
void;
case 2:
AccountEntryExtensionV2 v2;
}
ext;
};

/* AccountEntry

Main entry representing a user in Stellar. All transactions are
Expand All @@ -128,25 +162,15 @@ struct AccountEntry
// thresholds stores unsigned bytes: [weight of master|low|medium|high]
Thresholds thresholds;

Signer signers<20>; // possible signers for this account
Signer signers<MAX_SIGNERS>; // possible signers for this account

// reserved for future use
union switch (int v)
{
case 0:
void;
case 1:
struct
{
Liabilities liabilities;

union switch (int v)
{
case 0:
void;
}
ext;
} v1;
AccountEntryExtensionV1 v1;
}
ext;
};
Expand Down Expand Up @@ -260,6 +284,94 @@ struct DataEntry
ext;
};

enum ClaimPredicateType
{
CLAIM_PREDICATE_UNCONDITIONAL = 0,
CLAIM_PREDICATE_AND = 1,
CLAIM_PREDICATE_OR = 2,
CLAIM_PREDICATE_NOT = 3,
CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME = 4,
CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5
};

union ClaimPredicate switch (ClaimPredicateType type)
{
case CLAIM_PREDICATE_UNCONDITIONAL:
void;
case CLAIM_PREDICATE_AND:
ClaimPredicate andPredicates<2>;
case CLAIM_PREDICATE_OR:
ClaimPredicate orPredicates<2>;
case CLAIM_PREDICATE_NOT:
ClaimPredicate* notPredicate;
case CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME:
int64 absBefore; // Predicate will be true if closeTime < absBefore
case CLAIM_PREDICATE_BEFORE_RELATIVE_TIME:
int64 relBefore; // Seconds since closeTime of the ledger in which the
// ClaimableBalanceEntry was created
};

enum ClaimantType
{
CLAIMANT_TYPE_V0 = 0
};

union Claimant switch (ClaimantType type)
{
case CLAIMANT_TYPE_V0:
struct
{
AccountID destination; // The account that can use this condition
ClaimPredicate predicate; // Claimable if predicate is true
} v0;
};

enum ClaimableBalanceIDType
{
CLAIMABLE_BALANCE_ID_TYPE_V0 = 0
};

union ClaimableBalanceID switch (ClaimableBalanceIDType type)
{
case CLAIMABLE_BALANCE_ID_TYPE_V0:
Hash v0;
};

struct ClaimableBalanceEntry
{
// Unique identifier for this ClaimableBalanceEntry
ClaimableBalanceID balanceID;

// List of claimants with associated predicate
Claimant claimants<10>;

// Any asset including native
Asset asset;

// Amount of asset
int64 amount;

// reserved for future use
union switch (int v)
{
case 0:
void;
}
ext;
};

struct LedgerEntryExtensionV1
{
SponsorshipDescriptor sponsoringID;

union switch (int v)
{
case 0:
void;
}
ext;
};

struct LedgerEntry
{
uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
Expand All @@ -274,6 +386,8 @@ struct LedgerEntry
OfferEntry offer;
case DATA:
DataEntry data;
case CLAIMABLE_BALANCE:
ClaimableBalanceEntry claimableBalance;
}
data;

Expand All @@ -282,10 +396,48 @@ struct LedgerEntry
{
case 0:
void;
case 1:
LedgerEntryExtensionV1 v1;
}
ext;
};

union LedgerKey switch (LedgerEntryType type)
{
case ACCOUNT:
struct
{
AccountID accountID;
} account;

case TRUSTLINE:
struct
{
AccountID accountID;
Asset asset;
} trustLine;

case OFFER:
struct
{
AccountID sellerID;
int64 offerID;
} offer;

case DATA:
struct
{
AccountID accountID;
string64 dataName;
} data;

case CLAIMABLE_BALANCE:
struct
{
ClaimableBalanceID balanceID;
} claimableBalance;
};

// list of all envelope types used in the application
// those are prefixes used when building signatures for
// the respective envelopes
Expand All @@ -296,6 +448,7 @@ enum EnvelopeType
ENVELOPE_TYPE_TX = 2,
ENVELOPE_TYPE_AUTH = 3,
ENVELOPE_TYPE_SCPVALUE = 4,
ENVELOPE_TYPE_TX_FEE_BUMP = 5
ENVELOPE_TYPE_TX_FEE_BUMP = 5,
ENVELOPE_TYPE_OP_ID = 6
};
}
31 changes: 0 additions & 31 deletions .xdr/Stellar-ledger.x
Original file line number Diff line number Diff line change
Expand Up @@ -114,37 +114,6 @@ case LEDGER_UPGRADE_BASE_RESERVE:
};

/* Entries used to define the bucket list */

union LedgerKey switch (LedgerEntryType type)
{
case ACCOUNT:
struct
{
AccountID accountID;
} account;

case TRUSTLINE:
struct
{
AccountID accountID;
Asset asset;
} trustLine;

case OFFER:
struct
{
AccountID sellerID;
int64 offerID;
} offer;

case DATA:
struct
{
AccountID accountID;
string64 dataName;
} data;
};

enum BucketEntryType
{
METAENTRY =
Expand Down
Loading