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

Replace BigInt object with {iu}128 #57

Merged
merged 2 commits into from
Nov 20, 2022
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
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
# Triggers the workflow on push or pull request events for main, curr or next.
push:
branches: [ "main" ]
branches: [ "main", "curr", "next" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "curr", "next" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down
39 changes: 17 additions & 22 deletions Stellar-contract.x
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,11 @@ enum SCObjectType
SCO_MAP = 1,
SCO_U64 = 2,
SCO_I64 = 3,
SCO_BYTES = 4,
SCO_BIG_INT = 5,
SCO_CONTRACT_CODE = 6,
SCO_ACCOUNT_ID = 7
SCO_U128 = 4,
SCO_I128 = 5,
SCO_BYTES = 6,
SCO_CONTRACT_CODE = 7,
SCO_ACCOUNT_ID = 8

// TODO: add more
};
Expand All @@ -232,22 +233,6 @@ const SCVAL_LIMIT = 256000;
typedef SCVal SCVec<SCVAL_LIMIT>;
typedef SCMapEntry SCMap<SCVAL_LIMIT>;

enum SCNumSign
{
NEGATIVE = -1,
ZERO = 0,
POSITIVE = 1
};

union SCBigInt switch (SCNumSign sign)
{
case ZERO:
void;
case POSITIVE:
case NEGATIVE:
opaque magnitude<256000>;
};

enum SCContractCodeType
{
SCCONTRACT_CODE_WASM_REF = 0,
Expand All @@ -262,6 +247,14 @@ case SCCONTRACT_CODE_TOKEN:
void;
};

struct Int128Parts {
// Both signed and unsigned 128-bit ints
// are transported in a pair of uint64s
// to reduce the risk of sign-extension.
uint64 lo;
uint64 hi;
};

union SCObject switch (SCObjectType type)
{
case SCO_VEC:
Expand All @@ -272,10 +265,12 @@ case SCO_U64:
uint64 u64;
case SCO_I64:
int64 i64;
case SCO_U128:
Int128Parts u128;
case SCO_I128:
Int128Parts i128;
case SCO_BYTES:
opaque bin<SCVAL_LIMIT>;
case SCO_BIG_INT:
SCBigInt bigInt;
case SCO_CONTRACT_CODE:
SCContractCode contractCode;
case SCO_ACCOUNT_ID:
Expand Down