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

[DO NOT MERGE] feature Hooks #2217

Closed
wants to merge 15 commits into from
154 changes: 141 additions & 13 deletions packages/ripple-binary-codec/src/enums/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
"Child": -2,
"Nickname": 110,
"Contract": 99,
"GeneratorMap": 103
"GeneratorMap": 103,
"Hook": 72,
"HookState": 118,
"HookDefinition": 68,
"EmittedTxn": 69
},
"FIELDS": [
[
Expand Down Expand Up @@ -321,6 +325,16 @@
"type": "UInt16"
}
],
[
"NetworkID",
{
"nth": 1,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"Flags",
{
Expand Down Expand Up @@ -761,6 +775,16 @@
"type": "UInt32"
}
],
[
"LockCount",
{
"nth": 47,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt32"
}
],
[
"IndexNext",
{
Expand Down Expand Up @@ -891,16 +915,6 @@
"type": "UInt64"
}
],
[
"HookOn",
{
"nth": 16,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "UInt64"
}
],
[
"HookInstructionCount",
{
Expand Down Expand Up @@ -1151,6 +1165,16 @@
"type": "Hash256"
}
],
[
"HookOn",
{
"nth": 20,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Hash256"
}
],
[
"Digest",
{
Expand Down Expand Up @@ -1281,6 +1305,26 @@
"type": "Hash256"
}
],
[
"OfferID",
{
"nth": 34,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Hash256"
}
],
[
"EscrowID",
{
"nth": 35,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Hash256"
}
],
[
"Amount",
{
Expand Down Expand Up @@ -1421,6 +1465,26 @@
"type": "Amount"
}
],
[
"HookCallbackFee",
{
"nth": 20,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"LockedBalance",
{
"nth": 21,
"isVLEncoded": false,
"isSerialized": true,
"isSigningField": true,
"type": "Amount"
}
],
[
"PublicKey",
{
Expand Down Expand Up @@ -1661,6 +1725,16 @@
"type": "Blob"
}
],
[
"Blob",
{
"nth": 26,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Blob"
}
],
[
"Account",
{
Expand Down Expand Up @@ -1801,6 +1875,16 @@
"type": "Vector256"
}
],
[
"HookNamespaces",
{
"nth": 5,
"isVLEncoded": true,
"isSerialized": true,
"isSigningField": true,
"type": "Vector256"
}
],
[
"Paths",
{
Expand Down Expand Up @@ -2176,6 +2260,10 @@
"telCAN_NOT_QUEUE_BLOCKED": -389,
"telCAN_NOT_QUEUE_FEE": -388,
"telCAN_NOT_QUEUE_FULL": -387,
"telWRONG_NETWORK": -386,
"telREQUIRES_NETWORK_ID": -385,
"telNETWORK_ID_MAKES_TX_NON_CANONICAL": -384,
"telNON_LOCAL_EMITTED_TXN": -383,

"temMALFORMED": -299,
"temBAD_AMOUNT": -298,
Expand Down Expand Up @@ -2215,6 +2303,16 @@
"temUNKNOWN": -264,
"temSEQ_AND_TICKET": -263,
"temBAD_NFTOKEN_TRANSFER_FEE": -262,
"temAMM_BAD_TOKENS": -261,
"temXCHAIN_EQUAL_DOOR_ACCOUNTS": -260,
"temXCHAIN_BAD_PROOF": -259,
"temXCHAIN_BRIDGE_BAD_ISSUES": -258,
"temXCHAIN_BRIDGE_NONDOOR_OWNER": -257,
"temXCHAIN_BRIDGE_BAD_MIN_ACCOUNT_CREATE_AMOUNT": -256,
"temXCHAIN_BRIDGE_BAD_REWARD_AMOUNT": -255,
"temXCHAIN_TOO_MANY_ATTESTATIONS": -254,
"temHOOK_DATA_TOO_LARGE": -253,
"temHOOK_REJECTED": -252,

"tefFAILURE": -199,
"tefALREADY": -198,
Expand Down Expand Up @@ -2250,6 +2348,8 @@
"terNO_RIPPLE": -90,
"terQUEUED": -89,
"terPRE_TICKET": -88,
"terNO_AMM": -87,
"terNO_HOOK": -86,

"tesSUCCESS": 0,

Expand Down Expand Up @@ -2291,14 +2391,40 @@
"tecKILLED": 150,
"tecHAS_OBLIGATIONS": 151,
"tecTOO_SOON": 152,
"tecHOOK_REJECTED": 153,
"tecMAX_SEQUENCE_REACHED": 154,
"tecNO_SUITABLE_NFTOKEN_PAGE": 155,
"tecNFTOKEN_BUY_SELL_MISMATCH": 156,
"tecNFTOKEN_OFFER_TYPE_MISMATCH": 157,
"tecCANT_ACCEPT_OWN_NFTOKEN_OFFER": 158,
"tecINSUFFICIENT_FUNDS": 159,
"tecOBJECT_NOT_FOUND": 160,
"tecINSUFFICIENT_PAYMENT": 161
"tecINSUFFICIENT_PAYMENT": 161,
"tecAMM_UNFUNDED": 162,
"tecAMM_BALANCE": 163,
"tecAMM_FAILED_DEPOSIT": 164,
"tecAMM_FAILED_WITHDRAW": 165,
"tecAMM_INVALID_TOKENS": 166,
"tecAMM_FAILED_BID": 167,
"tecAMM_FAILED_VOTE": 168,
"tecREQUIRES_FLAG": 169,
"tecPRECISION_LOSS": 170,
"tecBAD_XCHAIN_TRANSFER_ISSUE": 171,
"tecXCHAIN_NO_CLAIM_ID": 172,
"tecXCHAIN_BAD_CLAIM_ID": 173,
"tecXCHAIN_CLAIM_NO_QUORUM": 174,
"tecXCHAIN_PROOF_UNKNOWN_KEY": 175,
"tecXCHAIN_CREATE_ACCOUNT_NONXRP_ISSUE": 176,
"tecXCHAIN_WRONG_CHAIN": 177,
"tecXCHAIN_REWARD_MISMATCH": 178,
"tecXCHAIN_NO_SIGNERS_LIST": 179,
"tecXCHAIN_SENDING_ACCOUNT_MISMATCH": 180,
"tecXCHAIN_INSUFF_CREATE_AMOUNT": 181,
"tecXCHAIN_ACCOUNT_CREATE_PAST": 182,
"tecXCHAIN_ACCOUNT_CREATE_TOO_MANY": 183,
"tecXCHAIN_PAYMENT_FAILED": 184,
"tecXCHAIN_SELF_COMMIT": 185,
"tecXCHAIN_BAD_PUBLIC_KEY_ACCOUNT_PAIR": 186
},
"TRANSACTION_TYPES": {
"Invalid": -1,
Expand Down Expand Up @@ -2330,8 +2456,10 @@
"NFTokenCreateOffer": 27,
"NFTokenCancelOffer": 28,
"NFTokenAcceptOffer": 29,
"Invoke": 99,
"EnableAmendment": 100,
"SetFee": 101,
"UNLModify": 102
"UNLModify": 102,
"EmitFailure": 103
}
}
2 changes: 2 additions & 0 deletions packages/ripple-binary-codec/src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Field = DEFAULT_DEFINITIONS.field
* @brief: All valid transaction types
*/
const TRANSACTION_TYPES = DEFAULT_DEFINITIONS.transactionNames
const TRANSACTION_TYPE_MAP = DEFAULT_DEFINITIONS.transactionMap

export {
Bytes,
Expand All @@ -31,4 +32,5 @@ export {
TransactionResult,
TransactionType,
TRANSACTION_TYPES,
TRANSACTION_TYPE_MAP,
}
12 changes: 12 additions & 0 deletions packages/ripple-binary-codec/src/enums/xrpl-definitions-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class XrplDefinitionsBase {
transactionType: BytesLookup
// Valid transaction names
transactionNames: string[]
// Valid transaction names
transactionMap: Record<string, number>
// Maps serializable types to their TypeScript class implementation
dataTypes: Record<string, typeof SerializedType>

Expand Down Expand Up @@ -68,10 +70,20 @@ class XrplDefinitionsBase {
enums.FIELDS as Array<[string, FieldInfo]>,
enums.TYPES,
)

this.transactionNames = Object.entries(enums.TRANSACTION_TYPES)
.filter(([_key, value]) => value >= 0)
.map(([key, _value]) => key)

const ignoreList = ['EnableAmendment', 'SetFee', 'UNLModify', 'EmitFailure']
this.transactionMap = Object.assign(
{},
...Object.entries(enums.TRANSACTION_TYPES)

.filter(([_key, _value]) => _value >= 0 || ignoreList.includes(_key))
.map(([key, value]) => ({ [key]: value })),
)

this.dataTypes = {} // Filled in via associateTypes
this.associateTypes(types)
}
Expand Down
2 changes: 2 additions & 0 deletions packages/ripple-binary-codec/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { JsonObject } from './types/serialized-type'
import {
XrplDefinitionsBase,
TRANSACTION_TYPES,
TRANSACTION_TYPE_MAP,
DEFAULT_DEFINITIONS,
} from './enums'
import { XrplDefinitions } from './enums/xrpl-definitions'
Expand Down Expand Up @@ -134,6 +135,7 @@ export {
decodeQuality,
decodeLedgerData,
TRANSACTION_TYPES,
TRANSACTION_TYPE_MAP,
XrplDefinitions,
XrplDefinitionsBase,
DEFAULT_DEFINITIONS,
Expand Down
Loading