@eqlabs/assemblyscript
Advanced tools
Comparing version 0.0.0-alpha.1677675681 to 0.0.0-alpha.1680097351
@@ -320,2 +320,3 @@ /** | ||
} | ||
assemblyscript.setDisableStartGeneration(compilerOptions, opts.disableStartGeneration); | ||
assemblyscript.setMemoryBase(compilerOptions, opts.memoryBase >>> 0); | ||
@@ -322,0 +323,0 @@ assemblyscript.setTableBase(compilerOptions, opts.tableBase >>> 0); |
@@ -180,2 +180,11 @@ { | ||
}, | ||
"disableStartGeneration": { | ||
"category": "Features", | ||
"description": [ | ||
"Disable start function generation, which is enabled by default. ", | ||
"Useful for hooks" | ||
], | ||
"type": "b", | ||
"default" : false | ||
}, | ||
"runtime": { | ||
@@ -182,0 +191,0 @@ "category": "Features", |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.0.0-alpha.1677675681", | ||
"version": "0.0.0-alpha.1680097351", | ||
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>", | ||
@@ -14,0 +14,0 @@ "license": "Apache-2.0", |
@@ -0,1 +1,7 @@ | ||
export class TokenAmountSpec { | ||
currency: String; | ||
issuer: Account; | ||
value: DecimalFloat; | ||
} | ||
export class Amount { | ||
@@ -71,2 +77,35 @@ @inline | ||
@inline | ||
static fromToken(spec: TokenAmountSpec): Amount { | ||
let code = spec.currency; | ||
if (code.length != 3) | ||
rollback("", pack_error_code(code.length)); | ||
let buf = new ByteArray(48); | ||
let r = $float_sto( | ||
changetype<u32>(buf), 48, | ||
0, 0, 0, 0, | ||
spec.value.value, | ||
-1); | ||
if (r < 0) | ||
rollback("", pack_error_code(r)) | ||
// set the currency code | ||
let p = changetype<u32>(buf) + 8; | ||
store<u64>(p, 0); | ||
store<u32>(p + 8, 0); | ||
p += 12; | ||
store<u8>(p++, code[0]); | ||
store<u8>(p++, code[1]); | ||
store<u8>(p++, code[2]); | ||
store<u8>(p++, 0); | ||
store<u32>(p, 0); | ||
p += 4; | ||
// and source | ||
__rawcopy20(p, changetype<usize>(spec.issuer.bytes)); | ||
return new Amount(buf); | ||
} | ||
@inline | ||
static fromView(view: ByteView): Amount { | ||
@@ -82,2 +121,20 @@ let buf = new ByteArray(view.length); | ||
} | ||
@inline | ||
static makeCurrency(code: string): ByteArray { | ||
if (code.length != 3) | ||
rollback("", pack_error_code(code.length)); | ||
let a = new ByteArray(20); | ||
let ptr = changetype<u32>(a); | ||
store<u64>(ptr, 0); | ||
store<u32>(ptr + 8, 0); | ||
ptr += 12; | ||
store<u8>(ptr++, code[0]); | ||
store<u8>(ptr++, code[1]); | ||
store<u8>(ptr++, code[2]); | ||
store<u8>(ptr++, 0); | ||
store<u32>(ptr, 0); | ||
return a; | ||
} | ||
}; |
@@ -0,1 +1,6 @@ | ||
import { | ||
__accumulateupto7, | ||
__accumulateupto32 | ||
} from "./accumupto" | ||
// @ts-ignore: decorator | ||
@@ -21,7 +26,61 @@ @lazy | ||
@final | ||
class MemoEncoder { | ||
@inline | ||
constructor(public buffer: u32) { | ||
} | ||
@inline | ||
public apply(obj: MemoObject): void { | ||
let buf = this.buffer; | ||
store<u8>(buf++, 0xEA); | ||
let memoType = obj.memoType; | ||
let len = memoType.length; | ||
if (len) | ||
buf = ENCODE_SHORT_BLOB(buf, changetype<u32>(memoType), len, 0x7C); | ||
let memoData = obj.memoData; | ||
if (memoData) | ||
buf = ENCODE_SHORT_BLOB(buf, changetype<u32>(memoData), memoData.length, 0x7D); | ||
let memoFormat = obj.memoFormat; | ||
len = memoFormat.length; | ||
if (len) | ||
buf = ENCODE_SHORT_BLOB(buf, changetype<u32>(memoFormat), len, 0x7E); | ||
store<u8>(buf, 0xE1); | ||
this.buffer = buf + 1; | ||
} | ||
} | ||
@final | ||
class SignerEntryEncoder { | ||
@inline | ||
constructor(public buffer: u32) { | ||
} | ||
@inline | ||
public apply(entry: SignerEntry): void { | ||
let buf = this.buffer; | ||
store<u16>(buf, 0x13EB); | ||
let weight = entry.signerWeight; | ||
store<u8>(buf + 2, (weight >> 8) & 0xFF); | ||
store<u8>(buf + 3, weight & 0xFF); | ||
buf += 4; | ||
let walletLocator = entry.walletLocator; | ||
if (walletLocator) { | ||
store<u8>(buf, 0x57); | ||
__rawcopy32(buf + 1, changetype<u32>(walletLocator)); | ||
buf += 33; | ||
} | ||
buf = ENCODE_ACCOUNT(buf, changetype<u32>(entry.account.bytes), atACCOUNT); | ||
store<u8>(buf, 0xE1); | ||
this.buffer = buf + 1; | ||
} | ||
} | ||
@inline | ||
export function ENCODE_TL(buf: u32, tlamt: u32, uat: u8): u32 { | ||
store<u8>(buf, 0x60 + (uat & 0x0F)); | ||
for (let i = 0; max_iterations(6), i < 48; i += 8) | ||
store<u64>(buf + i + 1, load<u64>(tlamt + i)); | ||
__rawcopy48(buf + 1, tlamt); | ||
return buf + 49; | ||
@@ -31,2 +90,10 @@ } | ||
@inline | ||
export function ENCODE_TL_UNCOMMON(buf: u32, tlamt: u32, uat: u8): u32 { | ||
store<u8>(buf, 0x60); | ||
store<u8>(buf + 1, uat); | ||
__rawcopy48(buf + 2, tlamt); | ||
return buf + 50; | ||
} | ||
@inline | ||
export function ENCODE_TT(buf: u32, utt: u8): u32 { | ||
@@ -79,3 +146,3 @@ store<u8>(buf, 0x12); | ||
store<u8>(buf, 0x60 + (uat & 0x0F)); | ||
store<u8>(buf + 1, 0x40 + drops[0]); | ||
store<u8>(buf + 1, 0x40 + (drops[0] & 0x0F)); | ||
store<u8>(buf + 2, drops[1]); | ||
@@ -92,2 +159,17 @@ store<u8>(buf + 3, drops[2]); | ||
@inline | ||
export function ENCODE_DROPS_ARRAY_UNCOMMON(buf: u32, drops: ByteArray, uat: u8): u32 { | ||
store<u8>(buf, 0x60); | ||
store<u8>(buf + 1, uat); | ||
store<u8>(buf + 2, 0x40 + (drops[0] & 0x0F)); | ||
store<u8>(buf + 3, drops[1]); | ||
store<u8>(buf + 4, drops[2]); | ||
store<u8>(buf + 5, drops[3]); | ||
store<u8>(buf + 6, drops[4]); | ||
store<u8>(buf + 7, drops[5]); | ||
store<u8>(buf + 8, drops[6]); | ||
store<u8>(buf + 9, drops[7]); | ||
return buf + 10; | ||
} | ||
@inline | ||
export function ENCODE_ACCOUNT(buf: u32, account_id: u32, uat: u8): u32 { | ||
@@ -103,2 +185,24 @@ store<u8>(buf, 0x80 + uat); | ||
@inline | ||
export function ENCODE_SHORT_BLOB(buf: u32, ptr: u32, len: u32, tag: u8): u32 { | ||
store<u8>(buf, tag); | ||
store<u8>(buf + 1, len); | ||
__rawcopyupto127(buf + 2, ptr, len); | ||
return buf + 2 + len; | ||
} | ||
@inline | ||
export function ENCODE_HASH128(buf: u32, h: u32, uat: u8): u32 { | ||
store<u8>(buf, 0x40 | uat); | ||
__rawcopy16(buf + 1, h); | ||
return buf + 17; | ||
} | ||
@inline | ||
export function ENCODE_HASH256(buf: u32, h: u32, uat: u8): u32 { | ||
store<u8>(buf, 0x50 | uat); | ||
__rawcopy32(buf + 1, h); | ||
return buf + 33; | ||
} | ||
@inline | ||
export function _01_02_ENCODE_TT(buf: u32, tt: u8): u32 { | ||
@@ -109,2 +213,10 @@ return ENCODE_TT(buf, tt); | ||
@inline | ||
export function _01_04_ENCODE_TRANSFER_FEE(buf: u32, tf: u16): u32 { | ||
store<u8>(buf, 0x14); | ||
store<u8>(buf + 1, (tf >> 8) & 0xFF); | ||
store<u8>(buf + 2, tf & 0xFF); | ||
return buf + 3; | ||
} | ||
@inline | ||
export function _02_02_ENCODE_FLAGS(buf: u32, tag: u32): u32 { | ||
@@ -125,2 +237,12 @@ return ENCODE_UINT32_COMMON(buf, tag, 0x2); | ||
@inline | ||
export function _02_10_ENCODE_EXPIRATION(buf: u32, date: u32): u32 { | ||
return ENCODE_UINT32_COMMON(buf, date, 0xA); | ||
} | ||
@inline | ||
export function _02_11_ENCODE_TRANSFER_RATE(buf: u32, rate: u32): u32 { | ||
return ENCODE_UINT32_COMMON(buf, rate, 0xB); | ||
} | ||
@inline | ||
export function _02_14_ENCODE_TAG_DST(buf: u32, tag: u32): u32 { | ||
@@ -131,2 +253,24 @@ return ENCODE_UINT32_COMMON(buf, tag, 0xE); | ||
@inline | ||
export function _02_17_ENCODE_INVOICE_ID(buf: u32, iid: u32): u32 { | ||
store<u16>(buf, 0x1150); | ||
__rawcopy32(buf + 2, iid); | ||
return buf + 34; | ||
} | ||
@inline | ||
export function _02_20_ENCODE_QUALITY_IN(buf: u32, q: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, q, 0x14); | ||
} | ||
@inline | ||
export function _02_21_ENCODE_QUALITY_OUT(buf: u32, q: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, q, 0x15); | ||
} | ||
@inline | ||
export function _02_25_ENCODE_OFFER_SEQUENCE(buf: u32, seq: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, seq, 0x19); | ||
} | ||
@inline | ||
export function _02_26_ENCODE_FLS(buf: u32, fls: u32): u32 { | ||
@@ -142,2 +286,88 @@ return ENCODE_UINT32_UNCOMMON(buf, fls, 0x1A); | ||
@inline | ||
export function _02_33_ENCODE_SET_FLAG(buf: u32, fl: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, fl, 0x21); | ||
} | ||
@inline | ||
export function _02_34_ENCODE_CLEAR_FLAG(buf: u32, fl: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, fl, 0x22); | ||
} | ||
@inline | ||
export function _02_35_ENCODE_SIGNER_QUORUM(buf: u32, q: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, q, 0x23); | ||
} | ||
@inline | ||
export function _02_36_ENCODE_CANCEL_AFTER(buf: u32, d: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, d, 0x24); | ||
} | ||
@inline | ||
export function _02_37_ENCODE_FINISH_AFTER(buf: u32, d: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, d, 0x25); | ||
} | ||
@inline | ||
export function _02_39_ENCODE_SETTLE_DELAY(buf: u32, d: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, d, 0x27); | ||
} | ||
@inline | ||
export function _02_40_ENCODE_TICKET_COUNT(buf: u32, tc: u8): u32 { | ||
store<u32>(buf, 0x00002820); | ||
store<u8>(buf + 4, 0); | ||
store<u8>(buf + 5, tc); | ||
return buf + 6; | ||
} | ||
@inline | ||
export function _02_42_ENCODE_NFTOKEN_TAXON(buf: u32, t: u32): u32 { | ||
return ENCODE_UINT32_UNCOMMON(buf, t, 0x2A); | ||
} | ||
@inline | ||
export function _04_01_ENCODE_EMAIL_HASH(buf: u32, h: u32): u32 { | ||
return ENCODE_HASH128(buf, h, 0x01); | ||
} | ||
@inline | ||
export function _05_07_ENCODE_WALLET_LOCATOR(buf: u32, h: u32): u32 { | ||
return ENCODE_HASH256(buf, h, 0x07); | ||
} | ||
@inline | ||
export function _05_10_ENCODE_NFTOKEN_ID(buf: u32, h: u32): u32 { | ||
return ENCODE_HASH256(buf, h, 0x0A); | ||
} | ||
@inline | ||
export function _05_24_ENCODE_CHECK_ID(buf: u32, cid: u32): u32 { | ||
store<u16>(buf, 0x1850); | ||
__rawcopy32(buf + 2, cid); | ||
return buf + 34; | ||
} | ||
@inline | ||
export function _05_22_ENCODE_CHANNEL(buf: u32, cid: u32): u32 { | ||
store<u16>(buf, 0x1650); | ||
__rawcopy32(buf + 2, cid); | ||
return buf + 34; | ||
} | ||
@inline | ||
export function _05_28_ENCODE_NFTOKEN_BUY(buf: u32, offer: u32): u32 { | ||
store<u16>(buf, 0x1C50); | ||
__rawcopy32(buf + 2, offer); | ||
return buf + 34; | ||
} | ||
@inline | ||
export function _05_29_ENCODE_NFTOKEN_SELL(buf: u32, offer: u32): u32 { | ||
store<u16>(buf, 0x1D50); | ||
__rawcopy32(buf + 2, offer); | ||
return buf + 34; | ||
} | ||
@inline | ||
export function _06_01_ENCODE_DROPS_AMOUNT(buf: u32, drops: ByteArray): u32 { | ||
@@ -153,2 +383,32 @@ return ENCODE_DROPS_ARRAY(buf, drops, amAMOUNT); | ||
@inline | ||
export function _06_02_ENCODE_DROPS_BALANCE(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY(buf, drops, 2); | ||
} | ||
@inline | ||
export function _06_03_ENCODE_LIMIT_AMOUNT(buf: u32, amt: ByteArray): u32 { | ||
return ENCODE_TL(buf, changetype<u32>(amt), 3); | ||
} | ||
@inline | ||
export function _06_04_ENCODE_DROPS_TAKER_PAYS(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY(buf, drops, 4); | ||
} | ||
@inline | ||
export function _06_04_ENCODE_TL_TAKER_PAYS(buf: u32, tlamt: ByteArray): u32 { | ||
return ENCODE_TL(buf, changetype<u32>(tlamt), 4); | ||
} | ||
@inline | ||
export function _06_05_ENCODE_DROPS_TAKER_GETS(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY(buf, drops, 5); | ||
} | ||
@inline | ||
export function _06_05_ENCODE_TL_TAKER_GETS(buf: u32, tlamt: ByteArray): u32 { | ||
return ENCODE_TL(buf, changetype<u32>(tlamt), 5); | ||
} | ||
@inline | ||
export function _06_08_ENCODE_DROPS_FEE(buf: u32, drops: u64): u32 { | ||
@@ -159,5 +419,48 @@ return ENCODE_DROPS(buf, drops, amFEE); | ||
@inline | ||
export function _06_09_ENCODE_DROPS_SEND_MAX(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY(buf, drops, 9); | ||
} | ||
@inline | ||
export function _06_09_ENCODE_TL_SEND_MAX(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_TL(buf, changetype<u32>(drops), 9); | ||
} | ||
@inline | ||
export function _06_10_ENCODE_DROPS_DELIVER_MIN(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY(buf, drops, 10); | ||
} | ||
@inline | ||
export function _06_10_ENCODE_TL_DELIVER_MIN(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_TL(buf, changetype<u32>(drops), 10); | ||
} | ||
@inline | ||
export function _06_19_ENCODE_DROPS_BROKER_FEE(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_DROPS_ARRAY_UNCOMMON(buf, drops, 19); | ||
} | ||
@inline | ||
export function _06_19_ENCODE_TL_BROKER_FEE(buf: u32, drops: ByteArray): u32 { | ||
return ENCODE_TL_UNCOMMON(buf, changetype<u32>(drops), 19); | ||
} | ||
@inline | ||
export function _07_01_ENCODE_PUBLIC_KEY(buf: u32, key: u32): u32 { | ||
store<u16>(buf, 0x2171); | ||
__rawcopy33(buf + 2, key); | ||
return buf + 35; | ||
} | ||
@inline | ||
export function _07_02_ENCODE_MESSAGE_KEY(buf: u32, key: u32): u32 { | ||
store<u16>(buf, 0x2172); | ||
__rawcopy33(buf + 2, key); | ||
return buf + 35; | ||
} | ||
@inline | ||
export function _07_03_ENCODE_SIGNING_PUBKEY_NULL(buf: u32): u32 { | ||
store<u8>(buf, 0x73); | ||
store<u8>(buf + 1, 0x21); | ||
store<u16>(buf, 0x2173); | ||
store<u64>(buf + 2, 0); | ||
@@ -172,2 +475,28 @@ store<u64>(buf + 10, 0); | ||
@inline | ||
export function _07_05_ENCODE_URI(buf: u32, ptr: u32, len: u32): u32 { | ||
return ENCODE_SHORT_BLOB(buf, ptr, len, 0x75); | ||
} | ||
@inline | ||
export function _07_07_ENCODE_DOMAIN(buf: u32, ptr: u32, len: u32): u32 { | ||
return ENCODE_SHORT_BLOB(buf, ptr, len, 0x77); | ||
} | ||
@inline | ||
export function _07_16_ENCODE_FULFILLMENT(buf: u32, ptr: u32): u32 { | ||
store<u16>(buf, 0x1070); | ||
store<u8>(buf + 2, 0x24); | ||
__rawcopy36(buf + 3, ptr); | ||
return buf + 39; | ||
} | ||
@inline | ||
export function _07_17_ENCODE_CONDITION(buf: u32, ptr: u32): u32 { | ||
store<u16>(buf, 0x1170); | ||
store<u8>(buf + 2, 0x27); | ||
__rawcopy39(buf + 3, ptr); | ||
return buf + 42; | ||
} | ||
@inline | ||
export function _08_01_ENCODE_ACCOUNT_SRC(buf: u32, account_id: u32): u32 { | ||
@@ -178,4 +507,102 @@ return ENCODE_ACCOUNT(buf, account_id, atACCOUNT); | ||
@inline | ||
export function _08_02_ENCODE_ACCOUNT_OWNER(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, 0x02); | ||
} | ||
@inline | ||
export function _08_03_ENCODE_ACCOUNT_DST(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, atDESTINATION); | ||
} | ||
@inline | ||
export function _08_04_ENCODE_ACCOUNT_ISSUER(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, 0x04); | ||
} | ||
@inline | ||
export function _08_05_ENCODE_ACCOUNT_AUTHORIZE(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, 0x05); | ||
} | ||
@inline | ||
export function _08_06_ENCODE_ACCOUNT_UNAUTHORIZE(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, 0x06); | ||
} | ||
@inline | ||
export function _08_08_ENCODE_ACCOUNT_REGULAR_KEY(buf: u32, account_id: u32): u32 { | ||
return ENCODE_ACCOUNT(buf, account_id, 0x08); | ||
} | ||
@inline | ||
export function _08_09_ENCODE_NFTOKENMINTER(buf: u32, accid: u32): u32 { | ||
return ENCODE_SHORT_BLOB(buf, accid, 20, 0x89); | ||
} | ||
@inline | ||
export function _15_04_ENCODE_SIGNER_ENTRIES(buf: u32, entries: StaticArray<SignerEntry>): u32 { | ||
store<u8>(buf, 0xF4); | ||
let encoder = __accumulateupto32<StaticArray<SignerEntry>, SignerEntryEncoder>(entries, 0, new SignerEntryEncoder(buf + 1)); | ||
buf = encoder.buffer; | ||
store<u8>(buf, 0xF1); | ||
return buf + 1; | ||
} | ||
@inline | ||
export function _15_09_ENCODE_MEMOS(buf: u32, memos: StaticArray<MemoObject>): u32 { | ||
store<u8>(buf, 0xF9); | ||
let encoder = __accumulateupto7<StaticArray<MemoObject>, MemoEncoder>(memos, 0, new MemoEncoder(buf + 1)); | ||
buf = encoder.buffer; | ||
store<u8>(buf, 0xF1); | ||
return buf + 1; | ||
} | ||
@inline | ||
export function _15_09_ENCODE_RAW_MEMOS(buf: u32, rawMemos: ByteArray): u32 { | ||
store<u8>(buf, 0xF9); | ||
++buf; | ||
let l = rawMemos.length; | ||
__rawcopyupto255(buf, changetype<u32>(rawMemos), l); | ||
buf += l; | ||
store<u8>(buf, 0xF1); | ||
return buf + 1; | ||
} | ||
@inline | ||
export function _16_16_ENCODE_TICK_SIZE(buf: u32, ts: u8): u32 { | ||
let hi = <u32>ts << 24; | ||
store<u32>(buf, 0x101000 | hi); | ||
return buf + 4; | ||
} | ||
@inline | ||
export function _19_04_ENCODE_NFTOKEN_OFFERS(buf: u32, offers: StaticArray<ByteArray>): u32 { | ||
let count = offers.length; | ||
store<u16>(buf, 0x1304); | ||
let len = 32 * count; | ||
store<u8>(buf + 2, len); | ||
let start = 0; | ||
let cur_buf = buf + 3; | ||
if (count >= 3) { | ||
__rawcopy32(cur_buf, changetype<u32>(offers[0])); | ||
__rawcopy32(cur_buf + 32, changetype<u32>(offers[1])); | ||
__rawcopy32(cur_buf + 64, changetype<u32>(offers[2])); | ||
cur_buf += 96; | ||
count -= 3; | ||
start = 3; | ||
} | ||
if (count >= 2) { | ||
__rawcopy32(cur_buf, changetype<u32>(offers[start])); | ||
__rawcopy32(cur_buf + 32, changetype<u32>(offers[start + 1])); | ||
cur_buf += 64; | ||
count -= 2; | ||
start += 2; | ||
} | ||
if (count) | ||
__rawcopy32(cur_buf, changetype<u32>(offers[start])); | ||
return buf + 3 + len; | ||
} |
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_HOOK = 1; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_HOOK_STATE = 2; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_ACCOUNT = 3; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_AMENDMENTS = 4; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_CHILD = 5; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_SKIP = 6; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_FEES = 7; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_NEGATIVE_UNL = 8; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_LINE = 9; | ||
@@ -7,11 +39,70 @@ | ||
@lazy | ||
export const KEYLET_OFFER = 10; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_QUALITY = 11; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_EMITTED_DIR = 12; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_SIGNERS = 14; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_CHECK = 15; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_DEPOSIT_PREAUTH = 16; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_UNCHECKED = 17; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_OWNER_DIR = 18; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_PAGE = 19; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_ESCROW = 20; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_PAYCHAN = 21; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_EMITTED_TXN = 22; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_NFT_OFFER = 23; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const KEYLET_HOOK_DEFINITION = 24; | ||
const KEYLET_SIZE = 34; | ||
export class Keylet { | ||
@inline | ||
static getSigners(acc: Account): ByteArray { | ||
static getHook(acc: Account): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet(changetype<u32>(a), 34, KEYLET_SIGNERS, changetype<u32>(b), 20, 0, 0, 0, 0); | ||
if (r != 34) | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_HOOK, | ||
changetype<u32>(b), 20, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
@@ -23,6 +114,110 @@ | ||
@inline | ||
static getHookState(acc: Account, key: ByteArray, ns: ByteArray): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_HOOK_STATE, | ||
changetype<u32>(b), 20, | ||
changetype<u32>(key), key.length, | ||
changetype<u32>(ns), ns.length); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getAccount(acc: Account): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_ACCOUNT, | ||
changetype<u32>(b), 20, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getAmendments(): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_AMENDMENTS, | ||
0, 0, 0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getChild(key: ByteArray): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_CHILD, | ||
changetype<u32>(key), key.length, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getSkip(withLedgerIndex: bool = false, ledgerIndex: u32 = 0): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_SKIP, | ||
withLedgerIndex ? ledgerIndex : 0, | ||
withLedgerIndex ? 1 : 0, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getFees(): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_FEES, | ||
0, 0, 0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getNegativeUnl(): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_NEGATIVE_UNL, | ||
0, 0, 0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getTrustLine(high: Account, low: Account, currency: ByteArray): ByteArray { | ||
let res = new ByteArray(34); | ||
let r = $util_keylet(changetype<u32>(res), 34, KEYLET_LINE, changetype<u32>(high.bytes), 20, changetype<u32>(low.bytes), 20, changetype<u32>(currency), currency.length); | ||
if (r != 34) | ||
let r = $util_keylet( | ||
changetype<u32>(res), 34, | ||
KEYLET_LINE, | ||
changetype<u32>(high.bytes), 20, | ||
changetype<u32>(low.bytes), 20, | ||
changetype<u32>(currency), currency.length); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
@@ -32,2 +227,227 @@ | ||
} | ||
@inline | ||
static getOffer(acc: Account, val: u32, key: ByteArray | null): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_OFFER, | ||
changetype<u32>(b), 20, | ||
key ? changetype<u32>(key) : val, | ||
key ? key.length : 0, | ||
0, 0); | ||
if (r != KEYLET_SIZE) { | ||
rollback("", pack_error_code(r)); | ||
} | ||
return a; | ||
} | ||
@inline | ||
static getQuality(keylet: ByteArray, val: u64): ByteArray { | ||
let a = new ByteArray(34); | ||
let lo = <u32>(val) & 0xFFFFFFFF; | ||
let hi = <u32>(val >> 32); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_QUALITY, | ||
changetype<u32>(keylet), keylet.length, | ||
hi, | ||
lo, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getEmittedDir(): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_EMITTED_DIR, | ||
0, 0, 0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getSigners(acc: Account): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_SIGNERS, | ||
changetype<u32>(b), 20, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getCheck(acc: Account, val: u32, key: ByteArray | null): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_CHECK, | ||
changetype<u32>(b), 20, | ||
key ? changetype<u32>(key) : val, | ||
key ? key.length : 0, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getDepositAuth(acc1: Account, acc2: Account): ByteArray { | ||
let res = new ByteArray(34); | ||
let b = acc1.bytes; | ||
let c = acc2.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(res), 34, | ||
KEYLET_DEPOSIT_PREAUTH, | ||
changetype<u32>(b), 20, | ||
changetype<u32>(c), 20, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return res; | ||
} | ||
@inline | ||
static getUnchecked(key: ByteArray): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_UNCHECKED, | ||
changetype<u32>(key), key.length, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getOwnerDir(acc: Account): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_OWNER_DIR, | ||
changetype<u32>(b), 20, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getPage(key: ByteArray, val: u64): ByteArray { | ||
let a = new ByteArray(34); | ||
let lo = <u32>(val) & 0xFFFFFFFF; | ||
let hi = <u32>(val >> 32); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_PAGE, | ||
changetype<u32>(key), key.length, | ||
hi, | ||
lo, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getEscrow(acc: Account, val: u32, key: ByteArray | null): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_ESCROW, | ||
changetype<u32>(b), 20, | ||
key ? changetype<u32>(key) : val, | ||
key ? key.length : 0, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getPaychan(acc1: Account, acc2: Account, val: u32, key: ByteArray | null): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc1.bytes; | ||
let c = acc2.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_PAYCHAN, | ||
changetype<u32>(b), 20, | ||
changetype<u32>(c), 20, | ||
key ? changetype<u32>(key) : val, | ||
key ? key.length : 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getEmittedTxn(key: ByteArray): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_EMITTED_TXN, | ||
changetype<u32>(key), key.length, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getNftOffer(acc: Account, val: u32, key: ByteArray | null): ByteArray { | ||
let a = new ByteArray(34); | ||
let b = acc.bytes; | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_NFT_OFFER, | ||
changetype<u32>(b), 20, | ||
key ? changetype<u32>(key) : val, | ||
key ? key.length : 0, | ||
0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
@inline | ||
static getHookDefinition(key: ByteArray): ByteArray { | ||
let a = new ByteArray(34); | ||
let r = $util_keylet( | ||
changetype<u32>(a), 34, | ||
KEYLET_HOOK_DEFINITION, | ||
changetype<u32>(key), key.length, | ||
0, 0, 0, 0); | ||
if (r != KEYLET_SIZE) | ||
rollback("", pack_error_code(r)); | ||
return a; | ||
} | ||
} |
@@ -61,1 +61,23 @@ @global @inline | ||
} | ||
@global @inline | ||
export function __rawcopyupto127(dest: usize, ptr: usize, len: i32): void { | ||
if (len >= 64) { | ||
__rawcopy64(dest, ptr); | ||
dest += 64; | ||
ptr += 64; | ||
len -= 64; | ||
} | ||
__rawcopyupto63(dest, ptr, len); | ||
} | ||
@global @inline | ||
export function __rawcopyupto255(dest: usize, ptr: usize, len: i32): void { | ||
if (len >= 128) { | ||
__rawcopy128(dest, ptr); | ||
dest += 128; | ||
ptr += 128; | ||
len -= 128; | ||
} | ||
__rawcopyupto127(dest, ptr, len); | ||
} |
@@ -42,3 +42,6 @@ import { Typeinfo, TypeinfoFlags } from "./shared/typeinfo"; | ||
let buffer = __new(size, id); | ||
if (data) memory.copy(buffer, data, size); | ||
if (data) { | ||
if (size >= 64) throw new Error(""); | ||
__rawcopyupto63(buffer, data, <i32>size); | ||
} | ||
return buffer; | ||
@@ -45,0 +48,0 @@ } |
@@ -7,5 +7,3 @@ import { AL_MASK, OBJECT, OBJECT_OVERHEAD, BLOCK_MAXSIZE, BLOCK_OVERHEAD, BLOCK, OBJECT_MAXSIZE } from "./common"; | ||
// @ts-ignore: decorator | ||
@lazy let startOffset: usize = ((__heap_base + BLOCK_OVERHEAD + AL_MASK) & ~AL_MASK) - BLOCK_OVERHEAD; | ||
// @ts-ignore: decorator | ||
@lazy let offset: usize = startOffset; | ||
@lazy let offset: usize = 0; | ||
@@ -33,2 +31,5 @@ @inline function maybeGrowMemory(newOffset: usize): void { | ||
if (!offset) | ||
offset = ((__heap_base + BLOCK_OVERHEAD + AL_MASK) & ~AL_MASK) - BLOCK_OVERHEAD; | ||
let block = changetype<BLOCK>(offset); | ||
@@ -80,3 +81,3 @@ let ptr = offset + BLOCK_OVERHEAD; | ||
export function __reset(): void { // special | ||
offset = startOffset; | ||
offset = ((__heap_base + BLOCK_OVERHEAD + AL_MASK) & ~AL_MASK) - BLOCK_OVERHEAD; | ||
} | ||
@@ -83,0 +84,0 @@ |
@@ -54,5 +54,2 @@ /// <reference path="./rt/index.d.ts" /> | ||
let out = changetype<StaticArray<T>>(__new(outSize, idof<StaticArray<T>>())); | ||
if (ASC_RUNTIME != Runtime.Incremental) { | ||
memory.fill(changetype<usize>(out), 0, outSize); | ||
} | ||
return out; | ||
@@ -59,0 +56,0 @@ } |
@@ -6,3 +6,3 @@ /// <reference path="./rt/index.d.ts" /> | ||
import { __raweq128 } from "./util/raweq"; | ||
import { compareImpl, strtol, strtod, isSpace, isAscii, isFinalSigma, toLower8, toUpper8 } from "./util/string"; | ||
import { compareImpl, strtol, strtod, isSpace, isAscii, isFinalSigma, toLower8, toUpper8, hexlifyNibble, unhexlifyNibble } from "./util/string"; | ||
import { SPECIALS_UPPER, casemap, bsearch } from "./util/casemap"; | ||
@@ -73,2 +73,34 @@ import { E_INDEXOUTOFRANGE, E_INVALIDLENGTH, E_UNPAIRED_SURROGATE } from "./util/error"; | ||
@inline | ||
hexlify(): String { | ||
let len = this.length; | ||
if (len > 256) | ||
throw new Error(""); | ||
if (len == 0) return changetype<String>(""); | ||
let out = __new(2 * len, idof<String>()); | ||
for (let i = 0; max_iterations(256), i < len; ++i) { | ||
let j = 2 * i, c = this[i], hi = c / 16, lo = c % 16; | ||
store<u8>(out + j, hexlifyNibble(hi)); | ||
store<u8>(out + j + 1, hexlifyNibble(lo)); | ||
} | ||
return changetype<String>(out); | ||
} | ||
@inline | ||
unhexlify(): String { | ||
let len = this.length; | ||
if ((len > 512) || (len % 2)) | ||
throw new Error(""); | ||
if (len == 0) return changetype<String>(""); | ||
let outLen = len / 2; | ||
let out = __new(outLen, idof<String>()); | ||
for (let i = 0; max_iterations(256), i < outLen; ++i) { | ||
let j = 2 * i, hi = this[j], lo = this[j + 1]; | ||
store<u8>(out + i, 16 * unhexlifyNibble(hi) + unhexlifyNibble(lo)); | ||
} | ||
return changetype<String>(out); | ||
} | ||
endsWith(search: String, end: i32 = String.MAX_LENGTH): bool { | ||
@@ -75,0 +107,0 @@ end = min(max(end, 0), this.length); |
@@ -1,14 +0,1 @@ | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const COMPARE_EQUAL = 1; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const COMPARE_LESS = 2; | ||
// @ts-ignore: decorator | ||
@lazy | ||
export const COMPARE_GREATER = 4; | ||
export const enum TransactionType { | ||
@@ -113,9 +100,1 @@ AccountDelete = ttACCOUNT_DELETE, | ||
} | ||
export class EmitSpec { | ||
transactionType: TransactionType; | ||
destination: Account | null; | ||
amount: Amount | null; | ||
sourceTag: u32; | ||
destinationTag: u32; | ||
} |
@@ -48,1 +48,448 @@ export const enum CommonTransactionField { | ||
} | ||
export const enum AccountDeleteField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/accountdelete.html | ||
Destination = sfDestination, | ||
DestinationTag = sfDestinationTag, | ||
} | ||
export const enum AccountSetField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/accountset.html | ||
ClearFlag = sfClearFlag, | ||
Domain = sfDomain, | ||
EmailHash = sfEmailHash, | ||
MessageKey = sfMessageKey, | ||
NFTokenMinter = sfNFTokenMinter, | ||
SetFlag = sfSetFlag, | ||
TransferRate = sfTransferRate, | ||
TickSize = sfTickSize, | ||
WalletLocator = sfWalletLocator | ||
} | ||
export const enum CheckCancelField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/checkcancel.html | ||
CheckID = sfCheckID | ||
} | ||
export const enum CheckCashField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/checkcash.html | ||
CheckID = sfCheckID, | ||
DeliverMin = sfDeliverMin | ||
} | ||
export const enum CheckCreateField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/checkcreate.html | ||
Destination = sfDestination, | ||
SendMax = sfSendMax, | ||
DestinationTag = sfDestinationTag, | ||
Expiration = sfExpiration, | ||
InvoiceID = sfInvoiceID | ||
} | ||
export const enum DepositPreauthField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/depositpreauth.html | ||
Authorize = sfAuthorize, | ||
Unauthorize = sfUnauthorize | ||
} | ||
export const enum EscrowCancelField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/escrowcancel.html | ||
Owner = sfOwner, | ||
OfferSequence = sfOfferSequence | ||
} | ||
export const enum EscrowCreateField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/escrowcreate.html | ||
Amount = sfAmount, | ||
Destination = sfDestination, | ||
CancelAfter = sfCancelAfter, | ||
FinishAfter = sfFinishAfter, | ||
Condition = sfCondition, | ||
DestinationTag = sfDestinationTag | ||
} | ||
export const enum EscrowFinishField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/escrowfinish.html | ||
Owner = sfOwner, | ||
OfferSequence = sfOfferSequence, | ||
Condition = sfCondition, | ||
Fulfillment = sfFulfillment | ||
} | ||
export const enum NFTokenAcceptOfferField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/nftokenacceptoffer.html | ||
NFTokenSellOffer = sfNFTokenSellOffer, | ||
NFTokenBuyOffer = sfNFTokenBuyOffer, | ||
NFTokenBrokerFee = sfNFTokenBrokerFee | ||
} | ||
export const enum NFTokenBurnField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/nftokenburn.html | ||
NFTokenID = sfNFTokenID, | ||
Owner = sfOwner | ||
} | ||
export const enum NFTokenCreateOfferField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/nftokencreateoffer.html | ||
Owner = sfOwner, | ||
NFTokenID = sfNFTokenID, | ||
Amount = sfAmount, | ||
Expiration = sfExpiration, | ||
Destination = sfDestination | ||
} | ||
export const enum NFTokenMintField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/nftokenmint.html | ||
NFTokenTaxon = sfNFTokenTaxon, | ||
Issuer = sfIssuer, | ||
TransferFee = sfTransferFee, | ||
URI = sfURI | ||
} | ||
export const enum OfferCancelField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/offercancel.html | ||
OfferSequence = sfOfferSequence | ||
} | ||
export const enum OfferCreateField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/offercreate.html | ||
Expiration = sfExpiration, | ||
OfferSequence = sfOfferSequence, | ||
TakerGets = sfTakerGets, | ||
TakerPays = sfTakerPays | ||
} | ||
export const enum PaymentChannelClaimField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/paymentchannelclaim.html | ||
Channel = sfChannel, | ||
Balance = sfBalance, | ||
Amount = sfAmount, | ||
Signature = sfSignature, | ||
PublicKey = sfPublicKey | ||
} | ||
export const enum PaymentChannelFundField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/paymentchannelfund.html | ||
Channel = sfChannel, | ||
Amount = sfAmount, | ||
Expiration = sfExpiration | ||
} | ||
export const enum PaymentChannelCreateField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/paymentchannelcreate.html | ||
Amount = sfAmount, | ||
Destination = sfDestination, | ||
DestinationTag = sfDestinationTag, | ||
SettleDelay = sfSettleDelay, | ||
PublicKey = sfPublicKey, | ||
CancelAfter = sfCancelAfter | ||
} | ||
export const enum SetRegularKeyField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/setregularkey.html | ||
RegularKey = sfRegularKey | ||
} | ||
export const enum SignerListSetField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/signerlistset.html | ||
SignerQuorum = sfSignerQuorum, | ||
SignerEntries = sfSignerEntries | ||
} | ||
export const enum TicketCreateField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/ticketcreate.html | ||
TicketCount = sfTicketCount | ||
} | ||
export const enum TrustSetField { | ||
Account = sfAccount, | ||
TransactionType = sfTransactionType, | ||
Fee = sfFee, | ||
Sequence = sfSequence, | ||
AccountTxnID = sfAccountTxnID, | ||
Flags = sfFlags, | ||
LastLedgerSequence = sfLastLedgerSequence, | ||
Memos = sfMemos, | ||
Signers = sfSigners, | ||
SourceTag = sfSourceTag, | ||
SigningPubKey = sfSigningPubKey, | ||
TicketSequence = sfTicketSequence, | ||
TxnSignature = sfTxnSignature, | ||
// https://xrpl.org/trustset.html | ||
LimitAmount = sfLimitAmount, | ||
QualityIn = sfQualityIn, | ||
QualityOut = sfQualityOut | ||
} |
@@ -659,2 +659,21 @@ import { | ||
// @ts-ignore: decorator | ||
@inline | ||
export function hexlifyNibble(n: u32): i32 { | ||
return (n < 10) ? (CharCode._0 + n) : (CharCode.A + n - 10); | ||
} | ||
// @ts-ignore: decorator | ||
@inline | ||
export function unhexlifyNibble(h: i32): u32 { | ||
if ((CharCode._0 <= h) && (h <= CharCode._9)) | ||
return h - CharCode._0; | ||
else if ((CharCode.A <= h) && (h <= CharCode.Z)) | ||
return 10 + h - CharCode.A; | ||
else if ((CharCode.a <= h) && (h <= CharCode.z)) | ||
return 10 + h - CharCode.a; | ||
else | ||
throw new Error(""); | ||
} | ||
/** Parses a string to an integer (usually), using the specified radix. */ | ||
@@ -661,0 +680,0 @@ export function strtol<T>(str: string, radix: i32 = 0): T { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13132892
154
86853