Skip to content
Open
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
498 changes: 0 additions & 498 deletions contractsjs/@types/global.d.ts

This file was deleted.

5 changes: 2 additions & 3 deletions contractsjs/tests/base copy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback('ASSERT.error', 0)
}
}

const INVALID_ARGUMENT = -7
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_sign(undefined) === INVALID_ARGUMENT)

Expand Down
3 changes: 1 addition & 2 deletions contractsjs/tests/base.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DOESNT_EXIST } from 'jshooks-api'
const ASSERT = (x, code) => {
if (!x) {
rollback(x.toString(), code)
}
}

const DOESNT_EXIST = -5

const names = [
'706172616d30', // 'param0'
'706172616d31', // 'param1'
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatCompare.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const INVALID_FLOAT = -10024

const EQ = 0b001
const LT = 0b010
const GT = 0b100
Expand Down
12 changes: 7 additions & 5 deletions contractsjs/tests/floatDivide.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import {
DIVISION_BY_ZERO,
INVALID_ARGUMENT,
INVALID_FLOAT,
XFL_OVERFLOW,
} from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
Expand Down Expand Up @@ -51,11 +58,6 @@ function ASSERT_EQUAL(x: bigint, y: bigint): void {
}
}

const INVALID_ARGUMENT = -7
const DIVISION_BY_ZERO = -25
const XFL_OVERFLOW = -30
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_divide(undefined, float_one()) === INVALID_ARGUMENT)
ASSERT(float_divide(float_one(), undefined) === INVALID_ARGUMENT)
Expand Down
12 changes: 7 additions & 5 deletions contractsjs/tests/floatInt.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {
CANT_RETURN_NEGATIVE,
INVALID_ARGUMENT,
INVALID_FLOAT,
TOO_BIG,
} from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const TOO_BIG = -3
const INVALID_ARGUMENT = -7
const CANT_RETURN_NEGATIVE = -33
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_int(undefined, 1, 1) === INVALID_ARGUMENT)
ASSERT(float_int(1, undefined, 1) === INVALID_ARGUMENT)
Expand Down
6 changes: 2 additions & 4 deletions contractsjs/tests/floatInvert.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { DIVISION_BY_ZERO, INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const DIVISION_BY_ZERO = -25
const INVALID_FLOAT = -10024

const Hook = (arg) => {
// invalid argument
ASSERT(float_invert(undefined) === INVALID_ARGUMENT)
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatLog.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { COMPLEX_NOT_SUPPORTED, INVALID_ARGUMENT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const COMPLEX_NOT_SUPPORTED = -39

const Hook = (arg) => {
// invalid argument
ASSERT(float_log(undefined) === INVALID_ARGUMENT)
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatMantissa.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const INVALID_FLOAT = -10024

const Hook = (arg) => {
// invalid argument
ASSERT(float_mantissa(undefined) === INVALID_ARGUMENT)
Expand Down
6 changes: 2 additions & 4 deletions contractsjs/tests/floatMulratio.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT, XFL_OVERFLOW } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const XFL_OVERFLOW = -30
const INVALID_FLOAT = -10024

const Hook = (arg) => {
// invalid argument
ASSERT(float_mulratio(undefined, 1, 1, 1) === INVALID_ARGUMENT)
Expand Down
12 changes: 4 additions & 8 deletions contractsjs/tests/floatMultiply.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT, XFL_OVERFLOW } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const XFL_OVERFLOW = -30
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_multiply(undefined, float_one()) === INVALID_ARGUMENT)
ASSERT(float_multiply(float_one(), undefined) === INVALID_ARGUMENT)
Expand Down Expand Up @@ -53,12 +51,10 @@ const Hook = (arg) => {

// identity
ASSERT(
float_multiply(3189548536178311168n, float_one()),
3189548536178311168n
float_multiply(3189548536178311168n, float_one()) === 3189548536178311168n
)
ASSERT(
float_multiply(float_one(), 3189548536178311168n),
3189548536178311168n
float_multiply(float_one(), 3189548536178311168n) === 3189548536178311168n
)

// random multiplications
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatNegate.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const INVALID_ARGUMENT = -7
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_negate(undefined) === INVALID_ARGUMENT)

Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatRoot.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { COMPLEX_NOT_SUPPORTED, INVALID_ARGUMENT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback('ASSERT.error', 0)
}
}

const INVALID_ARGUMENT = -7
const COMPLEX_NOT_SUPPORTED = -39

const Hook = (arg) => {
ASSERT(float_root(undefined, 0) === INVALID_ARGUMENT)
ASSERT(float_root(0, undefined) === INVALID_ARGUMENT)
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/floatSet.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { INVALID_ARGUMENT, INVALID_FLOAT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback('ASSERT.error', 0)
}
}

const INVALID_ARGUMENT = -7
const INVALID_FLOAT = -10024

const Hook = (arg) => {
ASSERT(float_set(undefined, 0) === INVALID_ARGUMENT)
ASSERT(float_set(0, undefined) === INVALID_ARGUMENT)
Expand Down
3 changes: 1 addition & 2 deletions contractsjs/tests/hookAgain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const PREREQUISITE_NOT_MET = -9
const ALREADY_SET = -8
import { ALREADY_SET, PREREQUISITE_NOT_MET } from 'jshooks-api'

const Hook = (r) => {
if (r > 0) {
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/hookParam.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { DOESNT_EXIST, INVALID_ARGUMENT } from 'jshooks-api'

const ASSERT = (x) => {
if (!x) {
rollback(x.toString(), 0)
}
}

const DOESNT_EXIST = -5
const INVALID_ARGUMENT = -7

const names = [
'706172616d30', // 'param0'
'706172616d31', // 'param1'
Expand Down
4 changes: 2 additions & 2 deletions contractsjs/tests/hookParamSet1.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { DOESNT_EXIST } from 'jshooks-api'

const ASSERT = (x, code) => {
if (!x) {
rollback(x.toString(), code)
}
}

const DOESNT_EXIST = -5

const names = ['param0', 'param1', 'param2', 'param3']

function toHex(str) {
Expand Down
6 changes: 2 additions & 4 deletions contractsjs/tests/hookSkip.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { DOESNT_EXIST, INVALID_ARGUMENT, sfInvoiceID } from 'jshooks-api'

const ASSERT = (x, code) => {
if (!x) {
rollback(x.toString(), code)
}
}

const DOESNT_EXIST = -5
const INVALID_ARGUMENT = -7
const sfInvoiceID = 0x50011

const Hook = (arg) => {
// garbage check
ASSERT(hook_skip([], 0) === DOESNT_EXIST)
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/otxnParam.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { DOESNT_EXIST, INVALID_ARGUMENT } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const DOESNT_EXIST = -5
const INVALID_ARGUMENT = -7

const names = [
'706172616d30', // 'param0'
'706172616d31', // 'param1'
Expand Down
5 changes: 2 additions & 3 deletions contractsjs/tests/otxnSlot.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { INVALID_ARGUMENT, NO_FREE_SLOTS } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const INVALID_ARGUMENT = -7
const NO_FREE_SLOTS = -6

const Hook = (arg) => {
ASSERT(otxn_slot(256) === INVALID_ARGUMENT, 1)

Expand Down
4 changes: 2 additions & 2 deletions contractsjs/tests/otxnType.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { sfTransactionType } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const sfTransactionType = 0x10002

const Hook = (arg) => {
ASSERT(otxn_slot(1) === 1, 1)

Expand Down
14 changes: 8 additions & 6 deletions contractsjs/tests/slot.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import {
DOESNT_EXIST,
INVALID_ARGUMENT,
KEYLET_ACCOUNT,
TOO_BIG,
sfBalance,
} from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const INVALID_ARGUMENT = -7
const DOESNT_EXIST = -5
const TOO_BIG = -3
const KEYLET_ACCOUNT = 3
const sfBalance = 0x60002

const Hook = (arg) => {
// slot type check
ASSERT(slot(null) === INVALID_ARGUMENT, 1)
Expand Down
4 changes: 2 additions & 2 deletions contractsjs/tests/slotClear.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DOESNT_EXIST } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const DOESNT_EXIST = -5

const Hook = (arg) => {
ASSERT(otxn_slot(1) === 1, 1)

Expand Down
6 changes: 2 additions & 4 deletions contractsjs/tests/slotCount.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { DOESNT_EXIST, NOT_AN_ARRAY, sfMemos } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const DOESNT_EXIST = -5
const NOT_AN_ARRAY = -22
const sfMemos = 0xf0009

const Hook = (arg) => {
ASSERT(otxn_slot(1) === 1, 1)

Expand Down
6 changes: 2 additions & 4 deletions contractsjs/tests/slotFloat.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { DOESNT_EXIST, NOT_AN_AMOUNT, sfFee } from 'jshooks-api'

const ASSERT = (x, line) => {
if (!x) {
trace('line', line, false)
rollback(x.toString(), line)
}
}

const DOESNT_EXIST = -5
const NOT_AN_AMOUNT = -32
const sfFee = 0x60008

const Hook = (arg) => {
ASSERT(otxn_slot(1) === 1, 1)

Expand Down
Loading