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.
Files changed (170) hide show
  1. package/build/xrpl-latest-min.js +1 -1
  2. package/build/xrpl-latest-min.js.map +1 -1
  3. package/build/xrpl-latest.js +578 -3
  4. package/build/xrpl-latest.js.map +1 -1
  5. package/dist/npm/models/common/index.d.ts +6 -0
  6. package/dist/npm/models/common/index.d.ts.map +1 -1
  7. package/dist/npm/models/ledger/Bridge.d.ts +17 -0
  8. package/dist/npm/models/ledger/Bridge.d.ts.map +1 -0
  9. package/dist/npm/models/ledger/Bridge.js +3 -0
  10. package/dist/npm/models/ledger/Bridge.js.map +1 -0
  11. package/dist/npm/models/ledger/LedgerEntry.d.ts +4 -1
  12. package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
  13. package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts +16 -0
  14. package/dist/npm/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
  15. package/dist/npm/models/ledger/XChainOwnedClaimID.js +3 -0
  16. package/dist/npm/models/ledger/XChainOwnedClaimID.js.map +1 -0
  17. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
  18. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
  19. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
  20. package/dist/npm/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
  21. package/dist/npm/models/ledger/index.d.ts +4 -1
  22. package/dist/npm/models/ledger/index.d.ts.map +1 -1
  23. package/dist/npm/models/ledger/index.js.map +1 -1
  24. package/dist/npm/models/methods/accountObjects.d.ts +3 -3
  25. package/dist/npm/models/methods/accountObjects.d.ts.map +1 -1
  26. package/dist/npm/models/methods/ledgerEntry.d.ts +17 -0
  27. package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
  28. package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
  29. package/dist/npm/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
  30. package/dist/npm/models/transactions/XChainAccountCreateCommit.js +35 -0
  31. package/dist/npm/models/transactions/XChainAccountCreateCommit.js.map +1 -0
  32. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
  33. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
  34. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
  35. package/dist/npm/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
  36. package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
  37. package/dist/npm/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
  38. package/dist/npm/models/transactions/XChainAddClaimAttestation.js +68 -0
  39. package/dist/npm/models/transactions/XChainAddClaimAttestation.js.map +1 -0
  40. package/dist/npm/models/transactions/XChainClaim.d.ts +12 -0
  41. package/dist/npm/models/transactions/XChainClaim.d.ts.map +1 -0
  42. package/dist/npm/models/transactions/XChainClaim.js +39 -0
  43. package/dist/npm/models/transactions/XChainClaim.js.map +1 -0
  44. package/dist/npm/models/transactions/XChainCommit.d.ts +11 -0
  45. package/dist/npm/models/transactions/XChainCommit.d.ts.map +1 -0
  46. package/dist/npm/models/transactions/XChainCommit.js +33 -0
  47. package/dist/npm/models/transactions/XChainCommit.js.map +1 -0
  48. package/dist/npm/models/transactions/XChainCreateBridge.d.ts +10 -0
  49. package/dist/npm/models/transactions/XChainCreateBridge.d.ts.map +1 -0
  50. package/dist/npm/models/transactions/XChainCreateBridge.js +26 -0
  51. package/dist/npm/models/transactions/XChainCreateBridge.js.map +1 -0
  52. package/dist/npm/models/transactions/XChainCreateClaimID.d.ts +10 -0
  53. package/dist/npm/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
  54. package/dist/npm/models/transactions/XChainCreateClaimID.js +28 -0
  55. package/dist/npm/models/transactions/XChainCreateClaimID.js.map +1 -0
  56. package/dist/npm/models/transactions/XChainModifyBridge.d.ts +17 -0
  57. package/dist/npm/models/transactions/XChainModifyBridge.d.ts.map +1 -0
  58. package/dist/npm/models/transactions/XChainModifyBridge.js +27 -0
  59. package/dist/npm/models/transactions/XChainModifyBridge.js.map +1 -0
  60. package/dist/npm/models/transactions/common.d.ts +2 -1
  61. package/dist/npm/models/transactions/common.d.ts.map +1 -1
  62. package/dist/npm/models/transactions/common.js +11 -1
  63. package/dist/npm/models/transactions/common.js.map +1 -1
  64. package/dist/npm/models/transactions/index.d.ts +9 -1
  65. package/dist/npm/models/transactions/index.d.ts.map +1 -1
  66. package/dist/npm/models/transactions/index.js +3 -1
  67. package/dist/npm/models/transactions/index.js.map +1 -1
  68. package/dist/npm/models/transactions/transaction.d.ts +9 -1
  69. package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
  70. package/dist/npm/models/transactions/transaction.js +32 -0
  71. package/dist/npm/models/transactions/transaction.js.map +1 -1
  72. package/dist/npm/models/utils/flags.d.ts.map +1 -1
  73. package/dist/npm/models/utils/flags.js +4 -0
  74. package/dist/npm/models/utils/flags.js.map +1 -1
  75. package/dist/npm/snippets/src/bridgeTransfer.d.ts +2 -0
  76. package/dist/npm/snippets/src/bridgeTransfer.d.ts.map +1 -0
  77. package/dist/npm/snippets/src/bridgeTransfer.js +124 -0
  78. package/dist/npm/snippets/src/bridgeTransfer.js.map +1 -0
  79. package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
  80. package/dist/npm/src/models/common/index.d.ts +6 -0
  81. package/dist/npm/src/models/common/index.d.ts.map +1 -1
  82. package/dist/npm/src/models/ledger/Bridge.d.ts +17 -0
  83. package/dist/npm/src/models/ledger/Bridge.d.ts.map +1 -0
  84. package/dist/npm/src/models/ledger/Bridge.js +3 -0
  85. package/dist/npm/src/models/ledger/Bridge.js.map +1 -0
  86. package/dist/npm/src/models/ledger/LedgerEntry.d.ts +4 -1
  87. package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
  88. package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts +16 -0
  89. package/dist/npm/src/models/ledger/XChainOwnedClaimID.d.ts.map +1 -0
  90. package/dist/npm/src/models/ledger/XChainOwnedClaimID.js +3 -0
  91. package/dist/npm/src/models/ledger/XChainOwnedClaimID.js.map +1 -0
  92. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts +14 -0
  93. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.d.ts.map +1 -0
  94. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js +3 -0
  95. package/dist/npm/src/models/ledger/XChainOwnedCreateAccountClaimID.js.map +1 -0
  96. package/dist/npm/src/models/ledger/index.d.ts +4 -1
  97. package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
  98. package/dist/npm/src/models/ledger/index.js.map +1 -1
  99. package/dist/npm/src/models/methods/accountObjects.d.ts +3 -3
  100. package/dist/npm/src/models/methods/accountObjects.d.ts.map +1 -1
  101. package/dist/npm/src/models/methods/ledgerEntry.d.ts +17 -0
  102. package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
  103. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts +11 -0
  104. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.d.ts.map +1 -0
  105. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js +35 -0
  106. package/dist/npm/src/models/transactions/XChainAccountCreateCommit.js.map +1 -0
  107. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts +18 -0
  108. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.d.ts.map +1 -0
  109. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js +77 -0
  110. package/dist/npm/src/models/transactions/XChainAddAccountCreateAttestation.js.map +1 -0
  111. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts +17 -0
  112. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.d.ts.map +1 -0
  113. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js +68 -0
  114. package/dist/npm/src/models/transactions/XChainAddClaimAttestation.js.map +1 -0
  115. package/dist/npm/src/models/transactions/XChainClaim.d.ts +12 -0
  116. package/dist/npm/src/models/transactions/XChainClaim.d.ts.map +1 -0
  117. package/dist/npm/src/models/transactions/XChainClaim.js +39 -0
  118. package/dist/npm/src/models/transactions/XChainClaim.js.map +1 -0
  119. package/dist/npm/src/models/transactions/XChainCommit.d.ts +11 -0
  120. package/dist/npm/src/models/transactions/XChainCommit.d.ts.map +1 -0
  121. package/dist/npm/src/models/transactions/XChainCommit.js +33 -0
  122. package/dist/npm/src/models/transactions/XChainCommit.js.map +1 -0
  123. package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts +10 -0
  124. package/dist/npm/src/models/transactions/XChainCreateBridge.d.ts.map +1 -0
  125. package/dist/npm/src/models/transactions/XChainCreateBridge.js +26 -0
  126. package/dist/npm/src/models/transactions/XChainCreateBridge.js.map +1 -0
  127. package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts +10 -0
  128. package/dist/npm/src/models/transactions/XChainCreateClaimID.d.ts.map +1 -0
  129. package/dist/npm/src/models/transactions/XChainCreateClaimID.js +28 -0
  130. package/dist/npm/src/models/transactions/XChainCreateClaimID.js.map +1 -0
  131. package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts +17 -0
  132. package/dist/npm/src/models/transactions/XChainModifyBridge.d.ts.map +1 -0
  133. package/dist/npm/src/models/transactions/XChainModifyBridge.js +27 -0
  134. package/dist/npm/src/models/transactions/XChainModifyBridge.js.map +1 -0
  135. package/dist/npm/src/models/transactions/common.d.ts +2 -1
  136. package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
  137. package/dist/npm/src/models/transactions/common.js +11 -1
  138. package/dist/npm/src/models/transactions/common.js.map +1 -1
  139. package/dist/npm/src/models/transactions/index.d.ts +9 -1
  140. package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
  141. package/dist/npm/src/models/transactions/index.js +3 -1
  142. package/dist/npm/src/models/transactions/index.js.map +1 -1
  143. package/dist/npm/src/models/transactions/transaction.d.ts +9 -1
  144. package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
  145. package/dist/npm/src/models/transactions/transaction.js +32 -0
  146. package/dist/npm/src/models/transactions/transaction.js.map +1 -1
  147. package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
  148. package/dist/npm/src/models/utils/flags.js +4 -0
  149. package/dist/npm/src/models/utils/flags.js.map +1 -1
  150. package/package.json +3 -3
  151. package/src/models/common/index.ts +7 -0
  152. package/src/models/ledger/Bridge.ts +84 -0
  153. package/src/models/ledger/LedgerEntry.ts +6 -0
  154. package/src/models/ledger/XChainOwnedClaimID.ts +73 -0
  155. package/src/models/ledger/XChainOwnedCreateAccountClaimID.ts +60 -0
  156. package/src/models/ledger/index.ts +6 -0
  157. package/src/models/methods/accountObjects.ts +9 -0
  158. package/src/models/methods/ledgerEntry.ts +25 -0
  159. package/src/models/transactions/XChainAccountCreateCommit.ts +107 -0
  160. package/src/models/transactions/XChainAddAccountCreateAttestation.ts +225 -0
  161. package/src/models/transactions/XChainAddClaimAttestation.ts +198 -0
  162. package/src/models/transactions/XChainClaim.ts +103 -0
  163. package/src/models/transactions/XChainCommit.ts +95 -0
  164. package/src/models/transactions/XChainCreateBridge.ts +78 -0
  165. package/src/models/transactions/XChainCreateClaimID.ts +78 -0
  166. package/src/models/transactions/XChainModifyBridge.ts +93 -0
  167. package/src/models/transactions/common.ts +26 -1
  168. package/src/models/transactions/index.ts +13 -1
  169. package/src/models/transactions/transaction.ts +68 -1
  170. package/src/models/utils/flags.ts +5 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ Bridge,
2
3
  Check,
3
4
  DepositPreauth,
4
5
  Escrow,
@@ -7,11 +8,14 @@ import {
7
8
  RippleState,
8
9
  SignerList,
9
10
  Ticket,
11
+ XChainOwnedClaimID,
12
+ XChainOwnedCreateAccountClaimID,
10
13
  } from '../ledger'
11
14
 
12
15
  import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
13
16
 
14
17
  export type AccountObjectType =
18
+ | 'bridge'
15
19
  | 'check'
16
20
  | 'deposit_preauth'
17
21
  | 'escrow'
@@ -21,6 +25,8 @@ export type AccountObjectType =
21
25
  | 'signer_list'
22
26
  | 'state'
23
27
  | 'ticket'
28
+ | 'xchain_owned_create_account_claim_id'
29
+ | 'xchain_owned_claim_id'
24
30
 
25
31
  /**
26
32
  * The account_objects command returns the raw ledger format for all objects
@@ -64,6 +70,7 @@ export interface AccountObjectsRequest
64
70
  * PayChannel, a SignerList, a Ticket, or a RippleState.
65
71
  */
66
72
  export type AccountObject =
73
+ | Bridge
67
74
  | Check
68
75
  | DepositPreauth
69
76
  | Escrow
@@ -72,6 +79,8 @@ export type AccountObject =
72
79
  | SignerList
73
80
  | RippleState
74
81
  | Ticket
82
+ | XChainOwnedClaimID
83
+ | XChainOwnedCreateAccountClaimID
75
84
 
76
85
  /**
77
86
  * Response expected from an {@link AccountObjectsRequest}.
@@ -1,3 +1,4 @@
1
+ import { Currency, XChainBridge } from '../common'
1
2
  import { LedgerEntry } from '../ledger'
2
3
 
3
4
  import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
@@ -152,6 +153,30 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
152
153
  * Must be the object ID of the NFToken page, as hexadecimal
153
154
  */
154
155
  nft_page?: string
156
+
157
+ bridge_account?: string
158
+
159
+ bridge?: XChainBridge
160
+
161
+ xchain_claim_id?:
162
+ | {
163
+ locking_chain_door: string
164
+ locking_chain_issue: Currency
165
+ issuing_chain_door: string
166
+ issuing_chain_issue: Currency
167
+ xchain_claim_id: string | number
168
+ }
169
+ | string
170
+
171
+ xchain_create_account_claim_id?:
172
+ | {
173
+ locking_chain_door: string
174
+ locking_chain_issue: Currency
175
+ issuing_chain_door: string
176
+ issuing_chain_issue: Currency
177
+ xchain_create_account_claim_id: string | number
178
+ }
179
+ | string
155
180
  }
156
181
 
157
182
  /**
@@ -0,0 +1,107 @@
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 XChainAccountCreateCommit transaction creates a new account on one of the
13
+ * chains a bridge connects, which serves as the bridge entrance for that chain.
14
+ *
15
+ * Warning: This transaction should only be executed if the witness attestations
16
+ * will be reliably delivered to the destination chain. If the signatures aren't
17
+ * delivered, then account creation will be blocked until attestations are received.
18
+ * This can be used maliciously; to disable this transaction on XRP-XRP bridges,
19
+ * the bridge's MinAccountCreateAmount shouldn't be present.
20
+ *
21
+ * @category Transaction Models
22
+ */
23
+ export interface XChainAccountCreateCommit extends BaseTransaction {
24
+ TransactionType: 'XChainAccountCreateCommit'
25
+
26
+ /**
27
+ * The bridge to create accounts for.
28
+ */
29
+ XChainBridge: XChainBridge
30
+
31
+ /**
32
+ * The amount, in XRP, to be used to reward the witness servers for providing
33
+ * signatures. This must match the amount on the {@link Bridge} ledger object.
34
+ */
35
+ SignatureReward: Amount
36
+
37
+ /**
38
+ * The destination account on the destination chain.
39
+ */
40
+ Destination: string
41
+
42
+ /**
43
+ * The amount, in XRP, to use for account creation. This must be greater than or
44
+ * equal to the MinAccountCreateAmount specified in the {@link Bridge} ledger object.
45
+ */
46
+ Amount: Amount
47
+ }
48
+
49
+ /**
50
+ * Verify the form and type of a XChainAccountCreateCommit at runtime.
51
+ *
52
+ * @param tx - A XChainAccountCreateCommit Transaction.
53
+ * @throws When the XChainAccountCreateCommit is malformed.
54
+ */
55
+ // eslint-disable-next-line max-lines-per-function -- okay for this function, there's a lot of things to check
56
+ export function validateXChainAccountCreateCommit(
57
+ tx: Record<string, unknown>,
58
+ ): void {
59
+ validateBaseTransaction(tx)
60
+
61
+ if (tx.XChainBridge == null) {
62
+ throw new ValidationError(
63
+ 'XChainAccountCreateCommit: missing field XChainBridge',
64
+ )
65
+ }
66
+
67
+ if (!isXChainBridge(tx.XChainBridge)) {
68
+ throw new ValidationError(
69
+ 'XChainAccountCreateCommit: invalid field XChainBridge',
70
+ )
71
+ }
72
+
73
+ if (tx.SignatureReward == null) {
74
+ throw new ValidationError(
75
+ 'XChainAccountCreateCommit: missing field SignatureReward',
76
+ )
77
+ }
78
+
79
+ if (
80
+ typeof tx.SignatureReward !== 'number' &&
81
+ typeof tx.SignatureReward !== 'string'
82
+ ) {
83
+ throw new ValidationError(
84
+ 'XChainAccountCreateCommit: invalid field SignatureReward',
85
+ )
86
+ }
87
+
88
+ if (tx.Destination == null) {
89
+ throw new ValidationError(
90
+ 'XChainAccountCreateCommit: missing field Destination',
91
+ )
92
+ }
93
+
94
+ if (typeof tx.Destination !== 'string') {
95
+ throw new ValidationError(
96
+ 'XChainAccountCreateCommit: invalid field Destination',
97
+ )
98
+ }
99
+
100
+ if (tx.Amount == null) {
101
+ throw new ValidationError('XChainAccountCreateCommit: missing field Amount')
102
+ }
103
+
104
+ if (!isAmount(tx.Amount)) {
105
+ throw new ValidationError('XChainAccountCreateCommit: invalid field Amount')
106
+ }
107
+ }
@@ -0,0 +1,225 @@
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 XChainAddAccountCreateAttestation transaction provides an attestation
13
+ * from a witness server that a {@link XChainAccountCreateCommit} transaction
14
+ * occurred on the other chain.
15
+ *
16
+ * @category Transaction Models
17
+ */
18
+ export interface XChainAddAccountCreateAttestation extends BaseTransaction {
19
+ TransactionType: 'XChainAddAccountCreateAttestation'
20
+
21
+ /**
22
+ * The amount committed by the {@link XChainAccountCreateCommit} transaction
23
+ * on the source chain.
24
+ */
25
+ Amount: Amount
26
+
27
+ /**
28
+ * The account that should receive this signer's share of the SignatureReward.
29
+ */
30
+ AttestationRewardAccount: string
31
+
32
+ /**
33
+ * The account on the door account's signer list that is signing the transaction.
34
+ */
35
+ AttestationSignerAccount: string
36
+
37
+ /**
38
+ * The destination account for the funds on the destination chain.
39
+ */
40
+ Destination: string
41
+
42
+ /**
43
+ * The account on the source chain that submitted the {@link XChainAccountCreateCommit}
44
+ * transaction that triggered the event associated with the attestation.
45
+ */
46
+ OtherChainSource: string
47
+
48
+ /**
49
+ * The public key used to verify the signature.
50
+ */
51
+ PublicKey: string
52
+
53
+ /**
54
+ * The signature attesting to the event on the other chain.
55
+ */
56
+ Signature: string
57
+
58
+ /**
59
+ * The signature reward paid in the {@link XChainAccountCreateCommit} transaction.
60
+ */
61
+ SignatureReward: Amount
62
+
63
+ /**
64
+ * A boolean representing the chain where the event occurred.
65
+ */
66
+ WasLockingChainSend: 0 | 1
67
+
68
+ /**
69
+ * The counter that represents the order that the claims must be processed in.
70
+ */
71
+ XChainAccountCreateCount: number | string
72
+
73
+ /**
74
+ * The bridge associated with the attestation.
75
+ */
76
+ XChainBridge: XChainBridge
77
+ }
78
+
79
+ /**
80
+ * Verify the form and type of a XChainAddAccountCreateAttestation at runtime.
81
+ *
82
+ * @param tx - A XChainAddAccountCreateAttestation Transaction.
83
+ * @throws When the XChainAddAccountCreateAttestation is malformed.
84
+ */
85
+ // eslint-disable-next-line max-lines-per-function, max-statements, complexity -- okay for this function, lots of things to check
86
+ export function validateXChainAddAccountCreateAttestation(
87
+ tx: Record<string, unknown>,
88
+ ): void {
89
+ validateBaseTransaction(tx)
90
+
91
+ if (tx.Amount == null) {
92
+ throw new ValidationError(
93
+ 'XChainAddAccountCreateAttestation: missing field Amount',
94
+ )
95
+ }
96
+
97
+ if (!isAmount(tx.Amount)) {
98
+ throw new ValidationError(
99
+ 'XChainAddAccountCreateAttestation: invalid field Amount',
100
+ )
101
+ }
102
+
103
+ if (tx.AttestationRewardAccount == null) {
104
+ throw new ValidationError(
105
+ 'XChainAddAccountCreateAttestation: missing field AttestationRewardAccount',
106
+ )
107
+ }
108
+
109
+ if (typeof tx.AttestationRewardAccount !== 'string') {
110
+ throw new ValidationError(
111
+ 'XChainAddAccountCreateAttestation: invalid field AttestationRewardAccount',
112
+ )
113
+ }
114
+
115
+ if (tx.AttestationSignerAccount == null) {
116
+ throw new ValidationError(
117
+ 'XChainAddAccountCreateAttestation: missing field AttestationSignerAccount',
118
+ )
119
+ }
120
+
121
+ if (typeof tx.AttestationSignerAccount !== 'string') {
122
+ throw new ValidationError(
123
+ 'XChainAddAccountCreateAttestation: invalid field AttestationSignerAccount',
124
+ )
125
+ }
126
+
127
+ if (tx.Destination == null) {
128
+ throw new ValidationError(
129
+ 'XChainAddAccountCreateAttestation: missing field Destination',
130
+ )
131
+ }
132
+
133
+ if (typeof tx.Destination !== 'string') {
134
+ throw new ValidationError(
135
+ 'XChainAddAccountCreateAttestation: invalid field Destination',
136
+ )
137
+ }
138
+
139
+ if (tx.OtherChainSource == null) {
140
+ throw new ValidationError(
141
+ 'XChainAddAccountCreateAttestation: missing field OtherChainSource',
142
+ )
143
+ }
144
+
145
+ if (typeof tx.OtherChainSource !== 'string') {
146
+ throw new ValidationError(
147
+ 'XChainAddAccountCreateAttestation: invalid field OtherChainSource',
148
+ )
149
+ }
150
+
151
+ if (tx.PublicKey == null) {
152
+ throw new ValidationError(
153
+ 'XChainAddAccountCreateAttestation: missing field PublicKey',
154
+ )
155
+ }
156
+
157
+ if (typeof tx.PublicKey !== 'string') {
158
+ throw new ValidationError(
159
+ 'XChainAddAccountCreateAttestation: invalid field PublicKey',
160
+ )
161
+ }
162
+
163
+ if (tx.Signature == null) {
164
+ throw new ValidationError(
165
+ 'XChainAddAccountCreateAttestation: missing field Signature',
166
+ )
167
+ }
168
+
169
+ if (typeof tx.Signature !== 'string') {
170
+ throw new ValidationError(
171
+ 'XChainAddAccountCreateAttestation: invalid field Signature',
172
+ )
173
+ }
174
+
175
+ if (tx.SignatureReward == null) {
176
+ throw new ValidationError(
177
+ 'XChainAddAccountCreateAttestation: missing field SignatureReward',
178
+ )
179
+ }
180
+
181
+ if (!isAmount(tx.SignatureReward)) {
182
+ throw new ValidationError(
183
+ 'XChainAddAccountCreateAttestation: invalid field SignatureReward',
184
+ )
185
+ }
186
+
187
+ if (tx.WasLockingChainSend == null) {
188
+ throw new ValidationError(
189
+ 'XChainAddAccountCreateAttestation: missing field WasLockingChainSend',
190
+ )
191
+ }
192
+
193
+ if (tx.WasLockingChainSend !== 0 && tx.WasLockingChainSend !== 1) {
194
+ throw new ValidationError(
195
+ 'XChainAddAccountCreateAttestation: invalid field WasLockingChainSend',
196
+ )
197
+ }
198
+
199
+ if (tx.XChainAccountCreateCount == null) {
200
+ throw new ValidationError(
201
+ 'XChainAddAccountCreateAttestation: missing field XChainAccountCreateCount',
202
+ )
203
+ }
204
+
205
+ if (
206
+ typeof tx.XChainAccountCreateCount !== 'string' &&
207
+ typeof tx.XChainAccountCreateCount !== 'number'
208
+ ) {
209
+ throw new ValidationError(
210
+ 'XChainAddAccountCreateAttestation: invalid field XChainAccountCreateCount',
211
+ )
212
+ }
213
+
214
+ if (tx.XChainBridge == null) {
215
+ throw new ValidationError(
216
+ 'XChainAddAccountCreateAttestation: missing field XChainBridge',
217
+ )
218
+ }
219
+
220
+ if (!isXChainBridge(tx.XChainBridge)) {
221
+ throw new ValidationError(
222
+ 'XChainAddAccountCreateAttestation: invalid field XChainBridge',
223
+ )
224
+ }
225
+ }
@@ -0,0 +1,198 @@
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 XChainAddClaimAttestation transaction provides proof from a witness server,
13
+ * attesting to an {@link XChainCommit} transaction.
14
+ *
15
+ * @category Transaction Models
16
+ */
17
+ export interface XChainAddClaimAttestation extends BaseTransaction {
18
+ TransactionType: 'XChainAddClaimAttestation'
19
+
20
+ /**
21
+ * The amount committed by the {@link XChainCommit} transaction on the source chain.
22
+ */
23
+ Amount: Amount
24
+
25
+ /**
26
+ * The account that should receive this signer's share of the SignatureReward.
27
+ */
28
+ AttestationRewardAccount: string
29
+
30
+ /**
31
+ * The account on the door account's signer list that is signing the transaction.
32
+ */
33
+ AttestationSignerAccount: string
34
+
35
+ /**
36
+ * The destination account for the funds on the destination chain (taken from
37
+ * the {@link XChainCommit} transaction).
38
+ */
39
+ Destination?: string
40
+
41
+ /**
42
+ * The account on the source chain that submitted the {@link XChainCommit}
43
+ * transaction that triggered the event associated with the attestation.
44
+ */
45
+ OtherChainSource: string
46
+
47
+ /**
48
+ * The public key used to verify the attestation signature.
49
+ */
50
+ PublicKey: string
51
+
52
+ /**
53
+ * The signature attesting to the event on the other chain.
54
+ */
55
+ Signature: string
56
+
57
+ /**
58
+ * A boolean representing the chain where the event occurred.
59
+ */
60
+ WasLockingChainSend: 0 | 1
61
+
62
+ /**
63
+ * The bridge to use to transfer funds.
64
+ */
65
+ XChainBridge: XChainBridge
66
+
67
+ /**
68
+ * The XChainClaimID associated with the transfer, which was included in the
69
+ * {@link XChainCommit} transaction.
70
+ */
71
+ XChainClaimID: number | string
72
+ }
73
+
74
+ /**
75
+ * Verify the form and type of a XChainAddClaimAttestation at runtime.
76
+ *
77
+ * @param tx - A XChainAddClaimAttestation Transaction.
78
+ * @throws When the XChainAddClaimAttestation is malformed.
79
+ */
80
+ // eslint-disable-next-line max-lines-per-function, max-statements, complexity -- okay for this function, lots of things to check
81
+ export function validateXChainAddClaimAttestation(
82
+ tx: Record<string, unknown>,
83
+ ): void {
84
+ validateBaseTransaction(tx)
85
+
86
+ if (tx.Amount == null) {
87
+ throw new ValidationError('XChainAddClaimAttestation: missing field Amount')
88
+ }
89
+
90
+ if (!isAmount(tx.Amount)) {
91
+ throw new ValidationError('XChainAddClaimAttestation: invalid field Amount')
92
+ }
93
+
94
+ if (tx.AttestationRewardAccount == null) {
95
+ throw new ValidationError(
96
+ 'XChainAddClaimAttestation: missing field AttestationRewardAccount',
97
+ )
98
+ }
99
+
100
+ if (typeof tx.AttestationRewardAccount !== 'string') {
101
+ throw new ValidationError(
102
+ 'XChainAddClaimAttestation: invalid field AttestationRewardAccount',
103
+ )
104
+ }
105
+
106
+ if (tx.AttestationSignerAccount == null) {
107
+ throw new ValidationError(
108
+ 'XChainAddClaimAttestation: missing field AttestationSignerAccount',
109
+ )
110
+ }
111
+
112
+ if (typeof tx.AttestationSignerAccount !== 'string') {
113
+ throw new ValidationError(
114
+ 'XChainAddClaimAttestation: invalid field AttestationSignerAccount',
115
+ )
116
+ }
117
+
118
+ if (tx.Destination !== undefined && typeof tx.Destination !== 'string') {
119
+ throw new ValidationError(
120
+ 'XChainAddClaimAttestation: invalid field Destination',
121
+ )
122
+ }
123
+
124
+ if (tx.OtherChainSource == null) {
125
+ throw new ValidationError(
126
+ 'XChainAddClaimAttestation: missing field OtherChainSource',
127
+ )
128
+ }
129
+
130
+ if (typeof tx.OtherChainSource !== 'string') {
131
+ throw new ValidationError(
132
+ 'XChainAddClaimAttestation: invalid field OtherChainSource',
133
+ )
134
+ }
135
+
136
+ if (tx.PublicKey == null) {
137
+ throw new ValidationError(
138
+ 'XChainAddClaimAttestation: missing field PublicKey',
139
+ )
140
+ }
141
+
142
+ if (typeof tx.PublicKey !== 'string') {
143
+ throw new ValidationError(
144
+ 'XChainAddClaimAttestation: invalid field PublicKey',
145
+ )
146
+ }
147
+
148
+ if (tx.Signature == null) {
149
+ throw new ValidationError(
150
+ 'XChainAddClaimAttestation: missing field Signature',
151
+ )
152
+ }
153
+
154
+ if (typeof tx.Signature !== 'string') {
155
+ throw new ValidationError(
156
+ 'XChainAddClaimAttestation: invalid field Signature',
157
+ )
158
+ }
159
+
160
+ if (tx.WasLockingChainSend == null) {
161
+ throw new ValidationError(
162
+ 'XChainAddClaimAttestation: missing field WasLockingChainSend',
163
+ )
164
+ }
165
+
166
+ if (tx.WasLockingChainSend !== 0 && tx.WasLockingChainSend !== 1) {
167
+ throw new ValidationError(
168
+ 'XChainAddClaimAttestation: invalid field WasLockingChainSend',
169
+ )
170
+ }
171
+
172
+ if (tx.XChainBridge == null) {
173
+ throw new ValidationError(
174
+ 'XChainAddClaimAttestation: missing field XChainBridge',
175
+ )
176
+ }
177
+
178
+ if (!isXChainBridge(tx.XChainBridge)) {
179
+ throw new ValidationError(
180
+ 'XChainAddClaimAttestation: invalid field XChainBridge',
181
+ )
182
+ }
183
+
184
+ if (tx.XChainClaimID == null) {
185
+ throw new ValidationError(
186
+ 'XChainAddClaimAttestation: missing field XChainClaimID',
187
+ )
188
+ }
189
+
190
+ if (
191
+ typeof tx.XChainClaimID !== 'string' &&
192
+ typeof tx.XChainClaimID !== 'number'
193
+ ) {
194
+ throw new ValidationError(
195
+ 'XChainAddClaimAttestation: invalid field XChainClaimID',
196
+ )
197
+ }
198
+ }
@@ -0,0 +1,103 @@
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 XChainClaim transaction completes a cross-chain transfer of value. It
13
+ * allows a user to claim the value on the destination chain - the equivalent
14
+ * of the value locked on the source chain.
15
+ *
16
+ * @category Transaction Models
17
+ */
18
+ export interface XChainClaim extends BaseTransaction {
19
+ TransactionType: 'XChainClaim'
20
+
21
+ /**
22
+ * The bridge to use for the transfer.
23
+ */
24
+ XChainBridge: XChainBridge
25
+
26
+ /**
27
+ * The unique integer ID for the cross-chain transfer that was referenced in the
28
+ * corresponding {@link XChainCommit} transaction.
29
+ */
30
+ XChainClaimID: number | string
31
+
32
+ /**
33
+ * The destination account on the destination chain. It must exist or the
34
+ * transaction will fail. However, if the transaction fails in this case, the
35
+ * sequence number and collected signatures won't be destroyed, and the
36
+ * transaction can be rerun with a different destination.
37
+ */
38
+ Destination: string
39
+
40
+ /**
41
+ * An integer destination tag.
42
+ */
43
+ DestinationTag?: number
44
+
45
+ /**
46
+ * The amount to claim on the destination chain. This must match the amount
47
+ * attested to on the attestations associated with this XChainClaimID.
48
+ */
49
+ Amount: Amount
50
+ }
51
+
52
+ /**
53
+ * Verify the form and type of a XChainClaim at runtime.
54
+ *
55
+ * @param tx - A XChainClaim Transaction.
56
+ * @throws When the XChainClaim is malformed.
57
+ */
58
+ // eslint-disable-next-line complexity -- okay for this function, lots of things to check
59
+ export function validateXChainClaim(tx: Record<string, unknown>): void {
60
+ validateBaseTransaction(tx)
61
+
62
+ if (tx.XChainBridge == null) {
63
+ throw new ValidationError('XChainClaim: missing field XChainBridge')
64
+ }
65
+
66
+ if (!isXChainBridge(tx.XChainBridge)) {
67
+ throw new ValidationError('XChainClaim: invalid field XChainBridge')
68
+ }
69
+
70
+ if (tx.XChainClaimID == null) {
71
+ throw new ValidationError('XChainClaim: missing field XChainClaimID')
72
+ }
73
+
74
+ if (
75
+ typeof tx.XChainClaimID !== 'number' &&
76
+ typeof tx.XChainClaimID !== 'string'
77
+ ) {
78
+ throw new ValidationError('XChainClaim: invalid field XChainClaimID')
79
+ }
80
+
81
+ if (tx.Destination == null) {
82
+ throw new ValidationError('XChainClaim: missing field Destination')
83
+ }
84
+
85
+ if (typeof tx.Destination !== 'string') {
86
+ throw new ValidationError('XChainClaim: invalid field Destination')
87
+ }
88
+
89
+ if (
90
+ tx.DestinationTag !== undefined &&
91
+ typeof tx.DestinationTag !== 'number'
92
+ ) {
93
+ throw new ValidationError('XChainClaim: invalid field DestinationTag')
94
+ }
95
+
96
+ if (tx.Amount == null) {
97
+ throw new ValidationError('XChainClaim: missing field Amount')
98
+ }
99
+
100
+ if (!isAmount(tx.Amount)) {
101
+ throw new ValidationError('XChainClaim: invalid field Amount')
102
+ }
103
+ }