xrpl 2.11.0 → 2.12.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/xrpl-latest-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +578 -3
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +6 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/Bridge.d.ts +17 -0
- package/dist/npm/models/ledger/Bridge.d.ts.map +1 -0
- package/dist/npm/models/ledger/Bridge.js +3 -0
- package/dist/npm/models/ledger/Bridge.js.map +1 -0
- package/dist/npm/models/ledger/LedgerEntry.d.ts +4 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts +16 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.js +3 -0
- package/dist/npm/models/ledger/XChainOwnedClaimID.js.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
- package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
- package/dist/npm/models/ledger/index.d.ts +4 -1
- package/dist/npm/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.js.map +1 -1
- package/dist/npm/models/methods/accountObjects.d.ts +3 -3
- package/dist/npm/models/methods/accountObjects.d.ts.map +1 -1
- package/dist/npm/models/methods/ledgerEntry.d.ts +17 -0
- package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.js +35 -0
- package/dist/npm/models/transactions/XChainAccountCreateCommit.js.map +1 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
- package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.js +68 -0
- package/dist/npm/models/transactions/XChainAddClaimAttestation.js.map +1 -0
- package/dist/npm/models/transactions/XChainClaim.d.ts +12 -0
- package/dist/npm/models/transactions/XChainClaim.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainClaim.js +39 -0
- package/dist/npm/models/transactions/XChainClaim.js.map +1 -0
- package/dist/npm/models/transactions/XChainCommit.d.ts +11 -0
- package/dist/npm/models/transactions/XChainCommit.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCommit.js +33 -0
- package/dist/npm/models/transactions/XChainCommit.js.map +1 -0
- package/dist/npm/models/transactions/XChainCreateBridge.d.ts +10 -0
- package/dist/npm/models/transactions/XChainCreateBridge.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCreateBridge.js +26 -0
- package/dist/npm/models/transactions/XChainCreateBridge.js.map +1 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.d.ts +10 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.js +28 -0
- package/dist/npm/models/transactions/XChainCreateClaimID.js.map +1 -0
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts +17 -0
- package/dist/npm/models/transactions/XChainModifyBridge.d.ts.map +1 -0
- package/dist/npm/models/transactions/XChainModifyBridge.js +27 -0
- package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -0
- package/dist/npm/models/transactions/common.d.ts +2 -1
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +11 -1
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +9 -1
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +3 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +9 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +32 -0
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +4 -0
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/snippets/src/bridgeTransfer.d.ts +2 -0
- package/dist/npm/snippets/src/bridgeTransfer.d.ts.map +1 -0
- package/dist/npm/snippets/src/bridgeTransfer.js +124 -0
- package/dist/npm/snippets/src/bridgeTransfer.js.map +1 -0
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/models/common/index.d.ts +6 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/Bridge.d.ts +17 -0
- package/dist/npm/src/models/ledger/Bridge.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/Bridge.js +3 -0
- package/dist/npm/src/models/ledger/Bridge.js.map +1 -0
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts +4 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts +16 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.js +3 -0
- package/dist/npm/src/models/ledger/XChainOwnedClaimID.js.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
- package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
- package/dist/npm/src/models/ledger/index.d.ts +4 -1
- package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.js.map +1 -1
- package/dist/npm/src/models/methods/accountObjects.d.ts +3 -3
- package/dist/npm/src/models/methods/accountObjects.d.ts.map +1 -1
- package/dist/npm/src/models/methods/ledgerEntry.d.ts +17 -0
- package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js +35 -0
- package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
- package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js +68 -0
- package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainClaim.d.ts +12 -0
- package/dist/npm/src/models/transactions/XChainClaim.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainClaim.js +39 -0
- package/dist/npm/src/models/transactions/XChainClaim.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCommit.d.ts +11 -0
- package/dist/npm/src/models/transactions/XChainCommit.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCommit.js +33 -0
- package/dist/npm/src/models/transactions/XChainCommit.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts +10 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.js +26 -0
- package/dist/npm/src/models/transactions/XChainCreateBridge.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts +10 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.js +28 -0
- package/dist/npm/src/models/transactions/XChainCreateClaimID.js.map +1 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts +17 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.js +27 -0
- package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -0
- package/dist/npm/src/models/transactions/common.d.ts +2 -1
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +11 -1
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +9 -1
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +3 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +9 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +32 -0
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +4 -0
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/package.json +3 -3
- package/src/models/common/index.ts +7 -0
- package/src/models/ledger/Bridge.ts +84 -0
- package/src/models/ledger/LedgerEntry.ts +6 -0
- package/src/models/ledger/XChainOwnedClaimID.ts +73 -0
- package/src/models/ledger/XChainOwnedCreateAccountClaimID.ts +60 -0
- package/src/models/ledger/index.ts +6 -0
- package/src/models/methods/accountObjects.ts +9 -0
- package/src/models/methods/ledgerEntry.ts +25 -0
- package/src/models/transactions/XChainAccountCreateCommit.ts +107 -0
- package/src/models/transactions/XChainAddAccountCreateAttestation.ts +225 -0
- package/src/models/transactions/XChainAddClaimAttestation.ts +198 -0
- package/src/models/transactions/XChainClaim.ts +103 -0
- package/src/models/transactions/XChainCommit.ts +95 -0
- package/src/models/transactions/XChainCreateBridge.ts +78 -0
- package/src/models/transactions/XChainCreateClaimID.ts +78 -0
- package/src/models/transactions/XChainModifyBridge.ts +93 -0
- package/src/models/transactions/common.ts +26 -1
- package/src/models/transactions/index.ts +13 -1
- package/src/models/transactions/transaction.ts +68 -1
- package/src/models/utils/flags.ts +5 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Amount, XChainBridge } from '../common'
|
3
|
+
|
4
|
+
import {
|
5
|
+
BaseTransaction,
|
6
|
+
isAmount,
|
7
|
+
isXChainBridge,
|
8
|
+
validateBaseTransaction,
|
9
|
+
} from './common'
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The XChainCommit is the second step in a cross-chain transfer. It puts assets
|
13
|
+
* into trust on the locking chain so that they can be wrapped on the issuing
|
14
|
+
* chain, or burns wrapped assets on the issuing chain so that they can be returned
|
15
|
+
* on the locking chain.
|
16
|
+
*
|
17
|
+
* @category Transaction Models
|
18
|
+
*/
|
19
|
+
export interface XChainCommit extends BaseTransaction {
|
20
|
+
TransactionType: 'XChainCommit'
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The bridge to use to transfer funds.
|
24
|
+
*/
|
25
|
+
XChainBridge: XChainBridge
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The unique integer ID for a cross-chain transfer. This must be acquired on
|
29
|
+
* the destination chain (via a {@link XChainCreateClaimID} transaction) and
|
30
|
+
* checked from a validated ledger before submitting this transaction. If an
|
31
|
+
* incorrect sequence number is specified, the funds will be lost.
|
32
|
+
*/
|
33
|
+
XChainClaimID: number | string
|
34
|
+
|
35
|
+
/**
|
36
|
+
* The destination account on the destination chain. If this is not specified,
|
37
|
+
* the account that submitted the {@link XChainCreateClaimID} transaction on the
|
38
|
+
* destination chain will need to submit a {@link XChainClaim} transaction to
|
39
|
+
* claim the funds.
|
40
|
+
*/
|
41
|
+
OtherChainDestination?: string
|
42
|
+
|
43
|
+
/**
|
44
|
+
* The asset to commit, and the quantity. This must match the door account's
|
45
|
+
* LockingChainIssue (if on the locking chain) or the door account's
|
46
|
+
* IssuingChainIssue (if on the issuing chain).
|
47
|
+
*/
|
48
|
+
Amount: Amount
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Verify the form and type of a XChainCommit at runtime.
|
53
|
+
*
|
54
|
+
* @param tx - A XChainCommit Transaction.
|
55
|
+
* @throws When the XChainCommit is malformed.
|
56
|
+
*/
|
57
|
+
export function validateXChainCommit(tx: Record<string, unknown>): void {
|
58
|
+
validateBaseTransaction(tx)
|
59
|
+
|
60
|
+
if (tx.XChainBridge == null) {
|
61
|
+
throw new ValidationError('XChainCommit: missing field XChainBridge')
|
62
|
+
}
|
63
|
+
|
64
|
+
if (!isXChainBridge(tx.XChainBridge)) {
|
65
|
+
throw new ValidationError('XChainCommit: invalid field XChainBridge')
|
66
|
+
}
|
67
|
+
|
68
|
+
if (tx.XChainClaimID == null) {
|
69
|
+
throw new ValidationError('XChainCommit: missing field XChainClaimID')
|
70
|
+
}
|
71
|
+
|
72
|
+
if (
|
73
|
+
typeof tx.XChainClaimID !== 'number' &&
|
74
|
+
typeof tx.XChainClaimID !== 'string'
|
75
|
+
) {
|
76
|
+
throw new ValidationError('XChainCommit: invalid field XChainClaimID')
|
77
|
+
}
|
78
|
+
|
79
|
+
if (
|
80
|
+
tx.OtherChainDestination !== undefined &&
|
81
|
+
typeof tx.OtherChainDestination !== 'string'
|
82
|
+
) {
|
83
|
+
throw new ValidationError(
|
84
|
+
'XChainCommit: invalid field OtherChainDestination',
|
85
|
+
)
|
86
|
+
}
|
87
|
+
|
88
|
+
if (tx.Amount == null) {
|
89
|
+
throw new ValidationError('XChainCommit: missing field Amount')
|
90
|
+
}
|
91
|
+
|
92
|
+
if (!isAmount(tx.Amount)) {
|
93
|
+
throw new ValidationError('XChainCommit: invalid field Amount')
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Amount, XChainBridge } from '../common'
|
3
|
+
|
4
|
+
import {
|
5
|
+
BaseTransaction,
|
6
|
+
isAmount,
|
7
|
+
isXChainBridge,
|
8
|
+
validateBaseTransaction,
|
9
|
+
} from './common'
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The XChainCreateBridge transaction creates a new {@link Bridge} ledger object
|
13
|
+
* and defines a new cross-chain bridge entrance on the chain that the transaction
|
14
|
+
* is submitted on. It includes information about door accounts and assets for the
|
15
|
+
* bridge.
|
16
|
+
*
|
17
|
+
* @category Transaction Models
|
18
|
+
*/
|
19
|
+
export interface XChainCreateBridge extends BaseTransaction {
|
20
|
+
TransactionType: 'XChainCreateBridge'
|
21
|
+
|
22
|
+
/**
|
23
|
+
* The bridge (door accounts and assets) to create.
|
24
|
+
*/
|
25
|
+
XChainBridge: XChainBridge
|
26
|
+
|
27
|
+
/**
|
28
|
+
* The total amount to pay the witness servers for their signatures. This amount
|
29
|
+
* will be split among the signers.
|
30
|
+
*/
|
31
|
+
SignatureReward: Amount
|
32
|
+
|
33
|
+
/**
|
34
|
+
* The minimum amount, in XRP, required for a {@link XChainAccountCreateCommit}
|
35
|
+
* transaction. If this isn't present, the {@link XChainAccountCreateCommit}
|
36
|
+
* transaction will fail. This field can only be present on XRP-XRP bridges.
|
37
|
+
*/
|
38
|
+
MinAccountCreateAmount?: Amount
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Verify the form and type of a XChainCreateBridge at runtime.
|
43
|
+
*
|
44
|
+
* @param tx - A XChainCreateBridge Transaction.
|
45
|
+
* @throws When the XChainCreateBridge is malformed.
|
46
|
+
*/
|
47
|
+
export function validateXChainCreateBridge(tx: Record<string, unknown>): void {
|
48
|
+
validateBaseTransaction(tx)
|
49
|
+
|
50
|
+
if (tx.XChainBridge == null) {
|
51
|
+
throw new ValidationError('XChainCreateBridge: missing field XChainBridge')
|
52
|
+
}
|
53
|
+
|
54
|
+
if (!isXChainBridge(tx.XChainBridge)) {
|
55
|
+
throw new ValidationError('XChainCreateBridge: invalid field XChainBridge')
|
56
|
+
}
|
57
|
+
|
58
|
+
if (tx.SignatureReward == null) {
|
59
|
+
throw new ValidationError(
|
60
|
+
'XChainCreateBridge: missing field SignatureReward',
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
if (!isAmount(tx.SignatureReward)) {
|
65
|
+
throw new ValidationError(
|
66
|
+
'XChainCreateBridge: invalid field SignatureReward',
|
67
|
+
)
|
68
|
+
}
|
69
|
+
|
70
|
+
if (
|
71
|
+
tx.MinAccountCreateAmount !== undefined &&
|
72
|
+
!isAmount(tx.MinAccountCreateAmount)
|
73
|
+
) {
|
74
|
+
throw new ValidationError(
|
75
|
+
'XChainCreateBridge: invalid field MinAccountCreateAmount',
|
76
|
+
)
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Amount, XChainBridge } from '../common'
|
3
|
+
|
4
|
+
import {
|
5
|
+
BaseTransaction,
|
6
|
+
isAmount,
|
7
|
+
isXChainBridge,
|
8
|
+
validateBaseTransaction,
|
9
|
+
} from './common'
|
10
|
+
|
11
|
+
/**
|
12
|
+
* The XChainCreateClaimID transaction creates a new cross-chain claim ID that is
|
13
|
+
* used for a cross-chain transfer. A cross-chain claim ID represents one
|
14
|
+
* cross-chain transfer of value.
|
15
|
+
*
|
16
|
+
* @category Transaction Models
|
17
|
+
*/
|
18
|
+
export interface XChainCreateClaimID extends BaseTransaction {
|
19
|
+
TransactionType: 'XChainCreateClaimID'
|
20
|
+
|
21
|
+
/**
|
22
|
+
* The bridge to create the claim ID for.
|
23
|
+
*/
|
24
|
+
XChainBridge: XChainBridge
|
25
|
+
|
26
|
+
/**
|
27
|
+
* The amount, in XRP, to reward the witness servers for providing signatures.
|
28
|
+
* This must match the amount on the {@link Bridge} ledger object.
|
29
|
+
*/
|
30
|
+
SignatureReward: Amount
|
31
|
+
|
32
|
+
/**
|
33
|
+
* The account that must send the {@link XChainCommit} transaction on the source chain.
|
34
|
+
*/
|
35
|
+
OtherChainSource: string
|
36
|
+
}
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Verify the form and type of a XChainCreateClaimID at runtime.
|
40
|
+
*
|
41
|
+
* @param tx - A XChainCreateClaimID Transaction.
|
42
|
+
* @throws When the XChainCreateClaimID is malformed.
|
43
|
+
*/
|
44
|
+
export function validateXChainCreateClaimID(tx: Record<string, unknown>): void {
|
45
|
+
validateBaseTransaction(tx)
|
46
|
+
|
47
|
+
if (tx.XChainBridge == null) {
|
48
|
+
throw new ValidationError('XChainCreateClaimID: missing field XChainBridge')
|
49
|
+
}
|
50
|
+
|
51
|
+
if (!isXChainBridge(tx.XChainBridge)) {
|
52
|
+
throw new ValidationError('XChainCreateClaimID: invalid field XChainBridge')
|
53
|
+
}
|
54
|
+
|
55
|
+
if (tx.SignatureReward == null) {
|
56
|
+
throw new ValidationError(
|
57
|
+
'XChainCreateClaimID: missing field SignatureReward',
|
58
|
+
)
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!isAmount(tx.SignatureReward)) {
|
62
|
+
throw new ValidationError(
|
63
|
+
'XChainCreateClaimID: invalid field SignatureReward',
|
64
|
+
)
|
65
|
+
}
|
66
|
+
|
67
|
+
if (tx.OtherChainSource == null) {
|
68
|
+
throw new ValidationError(
|
69
|
+
'XChainCreateClaimID: missing field OtherChainSource',
|
70
|
+
)
|
71
|
+
}
|
72
|
+
|
73
|
+
if (typeof tx.OtherChainSource !== 'string') {
|
74
|
+
throw new ValidationError(
|
75
|
+
'XChainCreateClaimID: invalid field OtherChainSource',
|
76
|
+
)
|
77
|
+
}
|
78
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { Amount, XChainBridge } from '../common'
|
3
|
+
|
4
|
+
import {
|
5
|
+
BaseTransaction,
|
6
|
+
GlobalFlags,
|
7
|
+
isAmount,
|
8
|
+
isXChainBridge,
|
9
|
+
validateBaseTransaction,
|
10
|
+
} from './common'
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Enum representing values of {@link XChainModifyBridge} transaction flags.
|
14
|
+
*
|
15
|
+
* @category Transaction Flags
|
16
|
+
*/
|
17
|
+
export enum XChainModifyBridgeFlags {
|
18
|
+
/** Clears the MinAccountCreateAmount of the bridge. */
|
19
|
+
tfClearAccountCreateAmount = 0x00010000,
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Map of flags to boolean values representing {@link XChainModifyBridge} transaction
|
24
|
+
* flags.
|
25
|
+
*
|
26
|
+
* @category Transaction Flags
|
27
|
+
*/
|
28
|
+
export interface XChainModifyBridgeFlagsInterface extends GlobalFlags {
|
29
|
+
/** Clears the MinAccountCreateAmount of the bridge. */
|
30
|
+
tfClearAccountCreateAmount?: boolean
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* The XChainModifyBridge transaction allows bridge managers to modify the parameters
|
35
|
+
* of the bridge.
|
36
|
+
*
|
37
|
+
* @category Transaction Models
|
38
|
+
*/
|
39
|
+
export interface XChainModifyBridge extends BaseTransaction {
|
40
|
+
TransactionType: 'XChainModifyBridge'
|
41
|
+
|
42
|
+
/**
|
43
|
+
* The bridge to modify.
|
44
|
+
*/
|
45
|
+
XChainBridge: XChainBridge
|
46
|
+
|
47
|
+
/**
|
48
|
+
* The signature reward split between the witnesses for submitting attestations.
|
49
|
+
*/
|
50
|
+
SignatureReward?: Amount
|
51
|
+
|
52
|
+
/**
|
53
|
+
* The minimum amount, in XRP, required for a {@link XChainAccountCreateCommit}
|
54
|
+
* transaction. If this is not present, the {@link XChainAccountCreateCommit}
|
55
|
+
* transaction will fail. This field can only be present on XRP-XRP bridges.
|
56
|
+
*/
|
57
|
+
MinAccountCreateAmount?: Amount
|
58
|
+
|
59
|
+
Flags?: number | XChainModifyBridgeFlagsInterface
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Verify the form and type of a XChainModifyBridge at runtime.
|
64
|
+
*
|
65
|
+
* @param tx - A XChainModifyBridge Transaction.
|
66
|
+
* @throws When the XChainModifyBridge is malformed.
|
67
|
+
*/
|
68
|
+
export function validateXChainModifyBridge(tx: Record<string, unknown>): void {
|
69
|
+
validateBaseTransaction(tx)
|
70
|
+
|
71
|
+
if (tx.XChainBridge == null) {
|
72
|
+
throw new ValidationError('XChainModifyBridge: missing field XChainBridge')
|
73
|
+
}
|
74
|
+
|
75
|
+
if (!isXChainBridge(tx.XChainBridge)) {
|
76
|
+
throw new ValidationError('XChainModifyBridge: invalid field XChainBridge')
|
77
|
+
}
|
78
|
+
|
79
|
+
if (tx.SignatureReward !== undefined && !isAmount(tx.SignatureReward)) {
|
80
|
+
throw new ValidationError(
|
81
|
+
'XChainModifyBridge: invalid field SignatureReward',
|
82
|
+
)
|
83
|
+
}
|
84
|
+
|
85
|
+
if (
|
86
|
+
tx.MinAccountCreateAmount !== undefined &&
|
87
|
+
!isAmount(tx.MinAccountCreateAmount)
|
88
|
+
) {
|
89
|
+
throw new ValidationError(
|
90
|
+
'XChainModifyBridge: invalid field MinAccountCreateAmount',
|
91
|
+
)
|
92
|
+
}
|
93
|
+
}
|
@@ -4,7 +4,14 @@
|
|
4
4
|
import { TRANSACTION_TYPES } from 'ripple-binary-codec'
|
5
5
|
|
6
6
|
import { ValidationError } from '../../errors'
|
7
|
-
import {
|
7
|
+
import {
|
8
|
+
Amount,
|
9
|
+
Currency,
|
10
|
+
IssuedCurrencyAmount,
|
11
|
+
Memo,
|
12
|
+
Signer,
|
13
|
+
XChainBridge,
|
14
|
+
} from '../common'
|
8
15
|
import { onlyHasFields } from '../utils'
|
9
16
|
|
10
17
|
const MEMO_SIZE = 3
|
@@ -53,6 +60,7 @@ function isSigner(obj: unknown): boolean {
|
|
53
60
|
const XRP_CURRENCY_SIZE = 1
|
54
61
|
const ISSUE_SIZE = 2
|
55
62
|
const ISSUED_CURRENCY_SIZE = 3
|
63
|
+
const XCHAIN_BRIDGE_SIZE = 4
|
56
64
|
|
57
65
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
58
66
|
return value !== null && typeof value === 'object'
|
@@ -103,6 +111,23 @@ export function isAmount(amount: unknown): amount is Amount {
|
|
103
111
|
return typeof amount === 'string' || isIssuedCurrency(amount)
|
104
112
|
}
|
105
113
|
|
114
|
+
/**
|
115
|
+
* Verify the form and type of an XChainBridge at runtime.
|
116
|
+
*
|
117
|
+
* @param input - The input to check the form and type of.
|
118
|
+
* @returns Whether the XChainBridge is properly formed.
|
119
|
+
*/
|
120
|
+
export function isXChainBridge(input: unknown): input is XChainBridge {
|
121
|
+
return (
|
122
|
+
isRecord(input) &&
|
123
|
+
Object.keys(input).length === XCHAIN_BRIDGE_SIZE &&
|
124
|
+
typeof input.LockingChainDoor === 'string' &&
|
125
|
+
isCurrency(input.LockingChainIssue) &&
|
126
|
+
typeof input.IssuingChainDoor === 'string' &&
|
127
|
+
isCurrency(input.IssuingChainIssue)
|
128
|
+
)
|
129
|
+
}
|
130
|
+
|
106
131
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface -- no global flags right now, so this is fine
|
107
132
|
export interface GlobalFlags {}
|
108
133
|
|
@@ -25,6 +25,7 @@ export {
|
|
25
25
|
export { CheckCancel } from './checkCancel'
|
26
26
|
export { CheckCash } from './checkCash'
|
27
27
|
export { CheckCreate } from './checkCreate'
|
28
|
+
export { Clawback } from './clawback'
|
28
29
|
export { DepositPreauth } from './depositPreauth'
|
29
30
|
export { EscrowCancel } from './escrowCancel'
|
30
31
|
export { EscrowCreate } from './escrowCreate'
|
@@ -63,4 +64,15 @@ export { SignerListSet } from './signerListSet'
|
|
63
64
|
export { TicketCreate } from './ticketCreate'
|
64
65
|
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
|
65
66
|
export { UNLModify } from './UNLModify'
|
66
|
-
export {
|
67
|
+
export { XChainAddAccountCreateAttestation } from './XChainAddAccountCreateAttestation'
|
68
|
+
export { XChainAddClaimAttestation } from './XChainAddClaimAttestation'
|
69
|
+
export { XChainClaim } from './XChainClaim'
|
70
|
+
export { XChainCommit } from './XChainCommit'
|
71
|
+
export { XChainCreateBridge } from './XChainCreateBridge'
|
72
|
+
export { XChainCreateClaimID } from './XChainCreateClaimID'
|
73
|
+
export { XChainAccountCreateCommit } from './XChainAccountCreateCommit'
|
74
|
+
export {
|
75
|
+
XChainModifyBridge,
|
76
|
+
XChainModifyBridgeFlags,
|
77
|
+
XChainModifyBridgeFlagsInterface,
|
78
|
+
} from './XChainModifyBridge'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
/* eslint-disable
|
1
|
+
/* eslint-disable max-lines -- need to work with a lot of transactions in a switch statement */
|
2
|
+
/* eslint-disable complexity -- verifies many tx types hence a lot of checks needed */
|
2
3
|
/* eslint-disable max-lines-per-function -- need to work with a lot of Tx verifications */
|
3
4
|
|
4
5
|
import { ValidationError } from '../../errors'
|
@@ -57,6 +58,32 @@ import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
|
|
57
58
|
import { SignerListSet, validateSignerListSet } from './signerListSet'
|
58
59
|
import { TicketCreate, validateTicketCreate } from './ticketCreate'
|
59
60
|
import { TrustSet, validateTrustSet } from './trustSet'
|
61
|
+
import {
|
62
|
+
XChainAccountCreateCommit,
|
63
|
+
validateXChainAccountCreateCommit,
|
64
|
+
} from './XChainAccountCreateCommit'
|
65
|
+
import {
|
66
|
+
XChainAddAccountCreateAttestation,
|
67
|
+
validateXChainAddAccountCreateAttestation,
|
68
|
+
} from './XChainAddAccountCreateAttestation'
|
69
|
+
import {
|
70
|
+
XChainAddClaimAttestation,
|
71
|
+
validateXChainAddClaimAttestation,
|
72
|
+
} from './XChainAddClaimAttestation'
|
73
|
+
import { XChainClaim, validateXChainClaim } from './XChainClaim'
|
74
|
+
import { XChainCommit, validateXChainCommit } from './XChainCommit'
|
75
|
+
import {
|
76
|
+
XChainCreateBridge,
|
77
|
+
validateXChainCreateBridge,
|
78
|
+
} from './XChainCreateBridge'
|
79
|
+
import {
|
80
|
+
XChainCreateClaimID,
|
81
|
+
validateXChainCreateClaimID,
|
82
|
+
} from './XChainCreateClaimID'
|
83
|
+
import {
|
84
|
+
XChainModifyBridge,
|
85
|
+
validateXChainModifyBridge,
|
86
|
+
} from './XChainModifyBridge'
|
60
87
|
|
61
88
|
/**
|
62
89
|
* @category Transaction Models
|
@@ -93,6 +120,14 @@ export type Transaction =
|
|
93
120
|
| SignerListSet
|
94
121
|
| TicketCreate
|
95
122
|
| TrustSet
|
123
|
+
| XChainAddAccountCreateAttestation
|
124
|
+
| XChainAddClaimAttestation
|
125
|
+
| XChainClaim
|
126
|
+
| XChainCommit
|
127
|
+
| XChainCreateBridge
|
128
|
+
| XChainCreateClaimID
|
129
|
+
| XChainAccountCreateCommit
|
130
|
+
| XChainModifyBridge
|
96
131
|
|
97
132
|
/**
|
98
133
|
* @category Transaction Models
|
@@ -295,6 +330,38 @@ export function validate(transaction: Record<string, unknown>): void {
|
|
295
330
|
validateTrustSet(tx)
|
296
331
|
break
|
297
332
|
|
333
|
+
case 'XChainAddAccountCreateAttestation':
|
334
|
+
validateXChainAddAccountCreateAttestation(tx)
|
335
|
+
break
|
336
|
+
|
337
|
+
case 'XChainAddClaimAttestation':
|
338
|
+
validateXChainAddClaimAttestation(tx)
|
339
|
+
break
|
340
|
+
|
341
|
+
case 'XChainClaim':
|
342
|
+
validateXChainClaim(tx)
|
343
|
+
break
|
344
|
+
|
345
|
+
case 'XChainCommit':
|
346
|
+
validateXChainCommit(tx)
|
347
|
+
break
|
348
|
+
|
349
|
+
case 'XChainCreateBridge':
|
350
|
+
validateXChainCreateBridge(tx)
|
351
|
+
break
|
352
|
+
|
353
|
+
case 'XChainCreateClaimID':
|
354
|
+
validateXChainCreateClaimID(tx)
|
355
|
+
break
|
356
|
+
|
357
|
+
case 'XChainAccountCreateCommit':
|
358
|
+
validateXChainAccountCreateCommit(tx)
|
359
|
+
break
|
360
|
+
|
361
|
+
case 'XChainModifyBridge':
|
362
|
+
validateXChainModifyBridge(tx)
|
363
|
+
break
|
364
|
+
|
298
365
|
default:
|
299
366
|
throw new ValidationError(
|
300
367
|
`Invalid field TransactionType: ${tx.TransactionType}`,
|
@@ -15,6 +15,7 @@ import { PaymentFlags } from '../transactions/payment'
|
|
15
15
|
import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
|
16
16
|
import type { Transaction } from '../transactions/transaction'
|
17
17
|
import { TrustSetFlags } from '../transactions/trustSet'
|
18
|
+
import { XChainModifyBridgeFlags } from '../transactions/XChainModifyBridge'
|
18
19
|
|
19
20
|
import { isFlagEnabled } from '.'
|
20
21
|
|
@@ -47,6 +48,7 @@ export function parseAccountRootFlags(
|
|
47
48
|
*
|
48
49
|
* @param tx - A transaction to set its flags to its numeric representation.
|
49
50
|
*/
|
51
|
+
// eslint-disable-next-line complexity -- there's a lot of txs with flags
|
50
52
|
export function setTransactionFlagsToNumber(tx: Transaction): void {
|
51
53
|
if (tx.Flags == null) {
|
52
54
|
tx.Flags = 0
|
@@ -78,6 +80,9 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
|
|
78
80
|
case 'TrustSet':
|
79
81
|
tx.Flags = convertFlagsToNumber(tx.Flags, TrustSetFlags)
|
80
82
|
return
|
83
|
+
case 'XChainModifyBridge':
|
84
|
+
tx.Flags = convertFlagsToNumber(tx.Flags, XChainModifyBridgeFlags)
|
85
|
+
return
|
81
86
|
default:
|
82
87
|
tx.Flags = 0
|
83
88
|
}
|