xrpjson 0.1.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/LICENSE +21 -0
- package/README.md +183 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/fp/factories/account-delete.d.ts +33 -0
- package/dist/fp/factories/account-delete.d.ts.map +1 -0
- package/dist/fp/factories/account-delete.js +138 -0
- package/dist/fp/factories/account-delete.js.map +1 -0
- package/dist/fp/factories/account-set.d.ts +31 -0
- package/dist/fp/factories/account-set.d.ts.map +1 -0
- package/dist/fp/factories/account-set.js +44 -0
- package/dist/fp/factories/account-set.js.map +1 -0
- package/dist/fp/factories/amm-bid.d.ts +134 -0
- package/dist/fp/factories/amm-bid.d.ts.map +1 -0
- package/dist/fp/factories/amm-bid.js +82 -0
- package/dist/fp/factories/amm-bid.js.map +1 -0
- package/dist/fp/factories/amm-clawback.d.ts +166 -0
- package/dist/fp/factories/amm-clawback.d.ts.map +1 -0
- package/dist/fp/factories/amm-clawback.js +143 -0
- package/dist/fp/factories/amm-clawback.js.map +1 -0
- package/dist/fp/factories/amm-create.d.ts +91 -0
- package/dist/fp/factories/amm-create.d.ts.map +1 -0
- package/dist/fp/factories/amm-create.js +140 -0
- package/dist/fp/factories/amm-create.js.map +1 -0
- package/dist/fp/factories/amm-delete.d.ts +84 -0
- package/dist/fp/factories/amm-delete.d.ts.map +1 -0
- package/dist/fp/factories/amm-delete.js +36 -0
- package/dist/fp/factories/amm-delete.js.map +1 -0
- package/dist/fp/factories/amm-deposit.d.ts +109 -0
- package/dist/fp/factories/amm-deposit.d.ts.map +1 -0
- package/dist/fp/factories/amm-deposit.js +68 -0
- package/dist/fp/factories/amm-deposit.js.map +1 -0
- package/dist/fp/factories/amm-vote.d.ts +87 -0
- package/dist/fp/factories/amm-vote.d.ts.map +1 -0
- package/dist/fp/factories/amm-vote.js +53 -0
- package/dist/fp/factories/amm-vote.js.map +1 -0
- package/dist/fp/factories/amm-withdraw.d.ts +131 -0
- package/dist/fp/factories/amm-withdraw.d.ts.map +1 -0
- package/dist/fp/factories/amm-withdraw.js +147 -0
- package/dist/fp/factories/amm-withdraw.js.map +1 -0
- package/dist/fp/factories/batch.d.ts +133 -0
- package/dist/fp/factories/batch.d.ts.map +1 -0
- package/dist/fp/factories/batch.js +264 -0
- package/dist/fp/factories/batch.js.map +1 -0
- package/dist/fp/factories/check-cancel.d.ts +22 -0
- package/dist/fp/factories/check-cancel.d.ts.map +1 -0
- package/dist/fp/factories/check-cancel.js +119 -0
- package/dist/fp/factories/check-cancel.js.map +1 -0
- package/dist/fp/factories/check-cash.d.ts +84 -0
- package/dist/fp/factories/check-cash.d.ts.map +1 -0
- package/dist/fp/factories/check-cash.js +95 -0
- package/dist/fp/factories/check-cash.js.map +1 -0
- package/dist/fp/factories/check-create.d.ts +82 -0
- package/dist/fp/factories/check-create.d.ts.map +1 -0
- package/dist/fp/factories/check-create.js +101 -0
- package/dist/fp/factories/check-create.js.map +1 -0
- package/dist/fp/factories/clawback.d.ts +160 -0
- package/dist/fp/factories/clawback.d.ts.map +1 -0
- package/dist/fp/factories/clawback.js +111 -0
- package/dist/fp/factories/clawback.js.map +1 -0
- package/dist/fp/factories/confidential-mpt-clawback.d.ts +24 -0
- package/dist/fp/factories/confidential-mpt-clawback.d.ts.map +1 -0
- package/dist/fp/factories/confidential-mpt-clawback.js +200 -0
- package/dist/fp/factories/confidential-mpt-clawback.js.map +1 -0
- package/dist/fp/factories/confidential-mpt-convert-back.d.ts +32 -0
- package/dist/fp/factories/confidential-mpt-convert-back.d.ts.map +1 -0
- package/dist/fp/factories/confidential-mpt-convert-back.js +203 -0
- package/dist/fp/factories/confidential-mpt-convert-back.js.map +1 -0
- package/dist/fp/factories/confidential-mpt-convert.d.ts +32 -0
- package/dist/fp/factories/confidential-mpt-convert.d.ts.map +1 -0
- package/dist/fp/factories/confidential-mpt-convert.js +209 -0
- package/dist/fp/factories/confidential-mpt-convert.js.map +1 -0
- package/dist/fp/factories/confidential-mpt-merge-inbox.d.ts +18 -0
- package/dist/fp/factories/confidential-mpt-merge-inbox.d.ts.map +1 -0
- package/dist/fp/factories/confidential-mpt-merge-inbox.js +130 -0
- package/dist/fp/factories/confidential-mpt-merge-inbox.js.map +1 -0
- package/dist/fp/factories/confidential-mpt-send.d.ts +38 -0
- package/dist/fp/factories/confidential-mpt-send.d.ts.map +1 -0
- package/dist/fp/factories/confidential-mpt-send.js +254 -0
- package/dist/fp/factories/confidential-mpt-send.js.map +1 -0
- package/dist/fp/factories/credential-accept.d.ts +23 -0
- package/dist/fp/factories/credential-accept.d.ts.map +1 -0
- package/dist/fp/factories/credential-accept.js +135 -0
- package/dist/fp/factories/credential-accept.js.map +1 -0
- package/dist/fp/factories/credential-create.d.ts +24 -0
- package/dist/fp/factories/credential-create.d.ts.map +1 -0
- package/dist/fp/factories/credential-create.js +204 -0
- package/dist/fp/factories/credential-create.js.map +1 -0
- package/dist/fp/factories/credential-delete.d.ts +33 -0
- package/dist/fp/factories/credential-delete.d.ts.map +1 -0
- package/dist/fp/factories/credential-delete.js +167 -0
- package/dist/fp/factories/credential-delete.js.map +1 -0
- package/dist/fp/factories/delegate-set.d.ts +52 -0
- package/dist/fp/factories/delegate-set.d.ts.map +1 -0
- package/dist/fp/factories/delegate-set.js +190 -0
- package/dist/fp/factories/delegate-set.js.map +1 -0
- package/dist/fp/factories/deposit-preauth.d.ts +183 -0
- package/dist/fp/factories/deposit-preauth.d.ts.map +1 -0
- package/dist/fp/factories/deposit-preauth.js +159 -0
- package/dist/fp/factories/deposit-preauth.js.map +1 -0
- package/dist/fp/factories/did-delete.d.ts +22 -0
- package/dist/fp/factories/did-delete.d.ts.map +1 -0
- package/dist/fp/factories/did-delete.js +126 -0
- package/dist/fp/factories/did-delete.js.map +1 -0
- package/dist/fp/factories/did-set.d.ts +68 -0
- package/dist/fp/factories/did-set.d.ts.map +1 -0
- package/dist/fp/factories/did-set.js +178 -0
- package/dist/fp/factories/did-set.js.map +1 -0
- package/dist/fp/factories/escrow-cancel.d.ts +28 -0
- package/dist/fp/factories/escrow-cancel.d.ts.map +1 -0
- package/dist/fp/factories/escrow-cancel.js +127 -0
- package/dist/fp/factories/escrow-cancel.js.map +1 -0
- package/dist/fp/factories/escrow-create.d.ts +103 -0
- package/dist/fp/factories/escrow-create.d.ts.map +1 -0
- package/dist/fp/factories/escrow-create.js +133 -0
- package/dist/fp/factories/escrow-create.js.map +1 -0
- package/dist/fp/factories/escrow-finish.d.ts +39 -0
- package/dist/fp/factories/escrow-finish.d.ts.map +1 -0
- package/dist/fp/factories/escrow-finish.js +173 -0
- package/dist/fp/factories/escrow-finish.js.map +1 -0
- package/dist/fp/factories/ledger-state-fix.d.ts +31 -0
- package/dist/fp/factories/ledger-state-fix.d.ts.map +1 -0
- package/dist/fp/factories/ledger-state-fix.js +163 -0
- package/dist/fp/factories/ledger-state-fix.js.map +1 -0
- package/dist/fp/factories/loan-broker-cover-clawback.d.ts +106 -0
- package/dist/fp/factories/loan-broker-cover-clawback.d.ts.map +1 -0
- package/dist/fp/factories/loan-broker-cover-clawback.js +122 -0
- package/dist/fp/factories/loan-broker-cover-clawback.js.map +1 -0
- package/dist/fp/factories/loan-broker-cover-deposit.d.ts +65 -0
- package/dist/fp/factories/loan-broker-cover-deposit.d.ts.map +1 -0
- package/dist/fp/factories/loan-broker-cover-deposit.js +81 -0
- package/dist/fp/factories/loan-broker-cover-deposit.js.map +1 -0
- package/dist/fp/factories/loan-broker-cover-withdraw.d.ts +96 -0
- package/dist/fp/factories/loan-broker-cover-withdraw.d.ts.map +1 -0
- package/dist/fp/factories/loan-broker-cover-withdraw.js +116 -0
- package/dist/fp/factories/loan-broker-cover-withdraw.js.map +1 -0
- package/dist/fp/factories/loan-broker-delete.d.ts +20 -0
- package/dist/fp/factories/loan-broker-delete.d.ts.map +1 -0
- package/dist/fp/factories/loan-broker-delete.js +94 -0
- package/dist/fp/factories/loan-broker-delete.js.map +1 -0
- package/dist/fp/factories/loan-broker-set.d.ts +108 -0
- package/dist/fp/factories/loan-broker-set.d.ts.map +1 -0
- package/dist/fp/factories/loan-broker-set.js +133 -0
- package/dist/fp/factories/loan-broker-set.js.map +1 -0
- package/dist/fp/factories/loan-delete.d.ts +18 -0
- package/dist/fp/factories/loan-delete.d.ts.map +1 -0
- package/dist/fp/factories/loan-delete.js +95 -0
- package/dist/fp/factories/loan-delete.js.map +1 -0
- package/dist/fp/factories/loan-manage.d.ts +72 -0
- package/dist/fp/factories/loan-manage.d.ts.map +1 -0
- package/dist/fp/factories/loan-manage.js +79 -0
- package/dist/fp/factories/loan-manage.js.map +1 -0
- package/dist/fp/factories/loan-pay.d.ts +70 -0
- package/dist/fp/factories/loan-pay.d.ts.map +1 -0
- package/dist/fp/factories/loan-pay.js +115 -0
- package/dist/fp/factories/loan-pay.js.map +1 -0
- package/dist/fp/factories/loan-set.d.ts +67 -0
- package/dist/fp/factories/loan-set.d.ts.map +1 -0
- package/dist/fp/factories/loan-set.js +102 -0
- package/dist/fp/factories/loan-set.js.map +1 -0
- package/dist/fp/factories/mptoken-authorize.d.ts +83 -0
- package/dist/fp/factories/mptoken-authorize.d.ts.map +1 -0
- package/dist/fp/factories/mptoken-authorize.js +63 -0
- package/dist/fp/factories/mptoken-authorize.js.map +1 -0
- package/dist/fp/factories/mptoken-issuance-create.d.ts +71 -0
- package/dist/fp/factories/mptoken-issuance-create.d.ts.map +1 -0
- package/dist/fp/factories/mptoken-issuance-create.js +135 -0
- package/dist/fp/factories/mptoken-issuance-create.js.map +1 -0
- package/dist/fp/factories/mptoken-issuance-destroy.d.ts +32 -0
- package/dist/fp/factories/mptoken-issuance-destroy.d.ts.map +1 -0
- package/dist/fp/factories/mptoken-issuance-destroy.js +105 -0
- package/dist/fp/factories/mptoken-issuance-destroy.js.map +1 -0
- package/dist/fp/factories/mptoken-issuance-set.d.ts +196 -0
- package/dist/fp/factories/mptoken-issuance-set.d.ts.map +1 -0
- package/dist/fp/factories/mptoken-issuance-set.js +333 -0
- package/dist/fp/factories/mptoken-issuance-set.js.map +1 -0
- package/dist/fp/factories/nftoken-accept-offer.d.ts +108 -0
- package/dist/fp/factories/nftoken-accept-offer.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-accept-offer.js +105 -0
- package/dist/fp/factories/nftoken-accept-offer.js.map +1 -0
- package/dist/fp/factories/nftoken-burn.d.ts +27 -0
- package/dist/fp/factories/nftoken-burn.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-burn.js +125 -0
- package/dist/fp/factories/nftoken-burn.js.map +1 -0
- package/dist/fp/factories/nftoken-cancel-offer.d.ts +19 -0
- package/dist/fp/factories/nftoken-cancel-offer.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-cancel-offer.js +143 -0
- package/dist/fp/factories/nftoken-cancel-offer.js.map +1 -0
- package/dist/fp/factories/nftoken-create-offer.d.ts +159 -0
- package/dist/fp/factories/nftoken-create-offer.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-create-offer.js +212 -0
- package/dist/fp/factories/nftoken-create-offer.js.map +1 -0
- package/dist/fp/factories/nftoken-mint.d.ts +155 -0
- package/dist/fp/factories/nftoken-mint.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-mint.js +165 -0
- package/dist/fp/factories/nftoken-mint.js.map +1 -0
- package/dist/fp/factories/nftoken-modify.d.ts +28 -0
- package/dist/fp/factories/nftoken-modify.d.ts.map +1 -0
- package/dist/fp/factories/nftoken-modify.js +209 -0
- package/dist/fp/factories/nftoken-modify.js.map +1 -0
- package/dist/fp/factories/offer-cancel.d.ts +21 -0
- package/dist/fp/factories/offer-cancel.d.ts.map +1 -0
- package/dist/fp/factories/offer-cancel.js +99 -0
- package/dist/fp/factories/offer-cancel.js.map +1 -0
- package/dist/fp/factories/offer-create.d.ts +125 -0
- package/dist/fp/factories/offer-create.d.ts.map +1 -0
- package/dist/fp/factories/offer-create.js +230 -0
- package/dist/fp/factories/offer-create.js.map +1 -0
- package/dist/fp/factories/oracle-delete.d.ts +21 -0
- package/dist/fp/factories/oracle-delete.d.ts.map +1 -0
- package/dist/fp/factories/oracle-delete.js +101 -0
- package/dist/fp/factories/oracle-delete.js.map +1 -0
- package/dist/fp/factories/oracle-set.d.ts +40 -0
- package/dist/fp/factories/oracle-set.d.ts.map +1 -0
- package/dist/fp/factories/oracle-set.js +257 -0
- package/dist/fp/factories/oracle-set.js.map +1 -0
- package/dist/fp/factories/payment-channel-claim.d.ts +153 -0
- package/dist/fp/factories/payment-channel-claim.d.ts.map +1 -0
- package/dist/fp/factories/payment-channel-claim.js +118 -0
- package/dist/fp/factories/payment-channel-claim.js.map +1 -0
- package/dist/fp/factories/payment-channel-create.d.ts +30 -0
- package/dist/fp/factories/payment-channel-create.d.ts.map +1 -0
- package/dist/fp/factories/payment-channel-create.js +172 -0
- package/dist/fp/factories/payment-channel-create.js.map +1 -0
- package/dist/fp/factories/payment-channel-fund.d.ts +25 -0
- package/dist/fp/factories/payment-channel-fund.d.ts.map +1 -0
- package/dist/fp/factories/payment-channel-fund.js +142 -0
- package/dist/fp/factories/payment-channel-fund.js.map +1 -0
- package/dist/fp/factories/payment.d.ts +65 -0
- package/dist/fp/factories/payment.d.ts.map +1 -0
- package/dist/fp/factories/payment.js +48 -0
- package/dist/fp/factories/payment.js.map +1 -0
- package/dist/fp/factories/permissioned-domain-delete.d.ts +18 -0
- package/dist/fp/factories/permissioned-domain-delete.d.ts.map +1 -0
- package/dist/fp/factories/permissioned-domain-delete.js +88 -0
- package/dist/fp/factories/permissioned-domain-delete.js.map +1 -0
- package/dist/fp/factories/permissioned-domain-set.d.ts +118 -0
- package/dist/fp/factories/permissioned-domain-set.d.ts.map +1 -0
- package/dist/fp/factories/permissioned-domain-set.js +100 -0
- package/dist/fp/factories/permissioned-domain-set.js.map +1 -0
- package/dist/fp/factories/set-regular-key.d.ts +30 -0
- package/dist/fp/factories/set-regular-key.d.ts.map +1 -0
- package/dist/fp/factories/set-regular-key.js +81 -0
- package/dist/fp/factories/set-regular-key.js.map +1 -0
- package/dist/fp/factories/signer-list-set.d.ts +61 -0
- package/dist/fp/factories/signer-list-set.d.ts.map +1 -0
- package/dist/fp/factories/signer-list-set.js +250 -0
- package/dist/fp/factories/signer-list-set.js.map +1 -0
- package/dist/fp/factories/sponsorship-set.d.ts +148 -0
- package/dist/fp/factories/sponsorship-set.d.ts.map +1 -0
- package/dist/fp/factories/sponsorship-set.js +201 -0
- package/dist/fp/factories/sponsorship-set.js.map +1 -0
- package/dist/fp/factories/sponsorship-transfer.d.ts +173 -0
- package/dist/fp/factories/sponsorship-transfer.d.ts.map +1 -0
- package/dist/fp/factories/sponsorship-transfer.js +195 -0
- package/dist/fp/factories/sponsorship-transfer.js.map +1 -0
- package/dist/fp/factories/ticket-create.d.ts +20 -0
- package/dist/fp/factories/ticket-create.d.ts.map +1 -0
- package/dist/fp/factories/ticket-create.js +120 -0
- package/dist/fp/factories/ticket-create.js.map +1 -0
- package/dist/fp/factories/trust-set.d.ts +100 -0
- package/dist/fp/factories/trust-set.d.ts.map +1 -0
- package/dist/fp/factories/trust-set.js +111 -0
- package/dist/fp/factories/trust-set.js.map +1 -0
- package/dist/fp/factories/vault-clawback.d.ts +83 -0
- package/dist/fp/factories/vault-clawback.d.ts.map +1 -0
- package/dist/fp/factories/vault-clawback.js +91 -0
- package/dist/fp/factories/vault-clawback.js.map +1 -0
- package/dist/fp/factories/vault-create.d.ts +51 -0
- package/dist/fp/factories/vault-create.d.ts.map +1 -0
- package/dist/fp/factories/vault-create.js +141 -0
- package/dist/fp/factories/vault-create.js.map +1 -0
- package/dist/fp/factories/vault-delete.d.ts +20 -0
- package/dist/fp/factories/vault-delete.d.ts.map +1 -0
- package/dist/fp/factories/vault-delete.js +103 -0
- package/dist/fp/factories/vault-delete.js.map +1 -0
- package/dist/fp/factories/vault-deposit.d.ts +56 -0
- package/dist/fp/factories/vault-deposit.d.ts.map +1 -0
- package/dist/fp/factories/vault-deposit.js +85 -0
- package/dist/fp/factories/vault-deposit.js.map +1 -0
- package/dist/fp/factories/vault-set.d.ts +32 -0
- package/dist/fp/factories/vault-set.d.ts.map +1 -0
- package/dist/fp/factories/vault-set.js +135 -0
- package/dist/fp/factories/vault-set.js.map +1 -0
- package/dist/fp/factories/vault-withdraw.d.ts +82 -0
- package/dist/fp/factories/vault-withdraw.d.ts.map +1 -0
- package/dist/fp/factories/vault-withdraw.js +122 -0
- package/dist/fp/factories/vault-withdraw.js.map +1 -0
- package/dist/fp/factories/xchain-account-create-commit.d.ts +180 -0
- package/dist/fp/factories/xchain-account-create-commit.d.ts.map +1 -0
- package/dist/fp/factories/xchain-account-create-commit.js +99 -0
- package/dist/fp/factories/xchain-account-create-commit.js.map +1 -0
- package/dist/fp/factories/xchain-add-account-create-attestation.d.ts +213 -0
- package/dist/fp/factories/xchain-add-account-create-attestation.d.ts.map +1 -0
- package/dist/fp/factories/xchain-add-account-create-attestation.js +95 -0
- package/dist/fp/factories/xchain-add-account-create-attestation.js.map +1 -0
- package/dist/fp/factories/xchain-add-claim-attestation.d.ts +206 -0
- package/dist/fp/factories/xchain-add-claim-attestation.d.ts.map +1 -0
- package/dist/fp/factories/xchain-add-claim-attestation.js +97 -0
- package/dist/fp/factories/xchain-add-claim-attestation.js.map +1 -0
- package/dist/fp/factories/xchain-claim.d.ts +187 -0
- package/dist/fp/factories/xchain-claim.d.ts.map +1 -0
- package/dist/fp/factories/xchain-claim.js +140 -0
- package/dist/fp/factories/xchain-claim.js.map +1 -0
- package/dist/fp/factories/xchain-commit.d.ts +168 -0
- package/dist/fp/factories/xchain-commit.d.ts.map +1 -0
- package/dist/fp/factories/xchain-commit.js +137 -0
- package/dist/fp/factories/xchain-commit.js.map +1 -0
- package/dist/fp/factories/xchain-create-bridge.d.ts +206 -0
- package/dist/fp/factories/xchain-create-bridge.d.ts.map +1 -0
- package/dist/fp/factories/xchain-create-bridge.js +100 -0
- package/dist/fp/factories/xchain-create-bridge.js.map +1 -0
- package/dist/fp/factories/xchain-create-claim-id.d.ts +199 -0
- package/dist/fp/factories/xchain-create-claim-id.d.ts.map +1 -0
- package/dist/fp/factories/xchain-create-claim-id.js +78 -0
- package/dist/fp/factories/xchain-create-claim-id.js.map +1 -0
- package/dist/fp/factories/xchain-modify-bridge.d.ts +198 -0
- package/dist/fp/factories/xchain-modify-bridge.d.ts.map +1 -0
- package/dist/fp/factories/xchain-modify-bridge.js +102 -0
- package/dist/fp/factories/xchain-modify-bridge.js.map +1 -0
- package/dist/fp/index.d.ts +124 -0
- package/dist/fp/index.d.ts.map +1 -0
- package/dist/fp/index.js +152 -0
- package/dist/fp/index.js.map +1 -0
- package/dist/fp/shape.d.ts +34 -0
- package/dist/fp/shape.d.ts.map +1 -0
- package/dist/fp/shape.js +80 -0
- package/dist/fp/shape.js.map +1 -0
- package/dist/types/amounts.d.ts +49 -0
- package/dist/types/amounts.d.ts.map +1 -0
- package/dist/types/amounts.js +8 -0
- package/dist/types/amounts.js.map +1 -0
- package/dist/types/base.d.ts +103 -0
- package/dist/types/base.d.ts.map +1 -0
- package/dist/types/base.js +2 -0
- package/dist/types/base.js.map +1 -0
- package/dist/types/common.d.ts +163 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/flags.d.ts +317 -0
- package/dist/types/flags.d.ts.map +1 -0
- package/dist/types/flags.js +253 -0
- package/dist/types/flags.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/transaction-types.d.ts +7 -0
- package/dist/types/transaction-types.d.ts.map +1 -0
- package/dist/types/transaction-types.js +2 -0
- package/dist/types/transaction-types.js.map +1 -0
- package/dist/validation/base.d.ts +8 -0
- package/dist/validation/base.d.ts.map +1 -0
- package/dist/validation/base.js +79 -0
- package/dist/validation/base.js.map +1 -0
- package/dist/validation/helpers.d.ts +42 -0
- package/dist/validation/helpers.d.ts.map +1 -0
- package/dist/validation/helpers.js +154 -0
- package/dist/validation/helpers.js.map +1 -0
- package/dist/validation/index.d.ts +3 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +3 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-bid.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/amm-bid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAkB7E,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,KAAK,EAAE,QAAQ,CAAC;IAChB,2DAA2D;IAC3D,MAAM,EAAE,QAAQ,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC1C;;;OAGG;IACH,YAAY,CAAC,EACT,aAAa,CAAC;QAAE,QAAQ,CAAC,WAAW,EAAE;YAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC,GACrE,SAAS,CAAC;IACd,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,MAAO,SAAQ,QAAQ,CAAC,WAAW,CAAC;IACnD,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IACnC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC;CAC/C;AAID,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAgGjD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isAccount, isCurrency, isIssuedCurrencyAmount, isRecord, isString, } from '../../validation/helpers.js';
|
|
2
|
+
import { ValidationError } from '../../errors.js';
|
|
3
|
+
import { buildFrozenTx, mergeForWith } from '../shape.js';
|
|
4
|
+
// ─── Spec constants ──────────────────────────────────────────────────
|
|
5
|
+
/** xrpl.js `MAX_AUTH_ACCOUNTS = 4` (xrpl.js AMMBid.ts line 13). */
|
|
6
|
+
const MAX_AUTH_ACCOUNTS = 4;
|
|
7
|
+
// ─── Factory ─────────────────────────────────────────────────────────
|
|
8
|
+
export function ammBid(props) {
|
|
9
|
+
// ── Account ── required, must be a valid XRPL classic address.
|
|
10
|
+
if (!isString(props.Account) || !isAccount(props.Account)) {
|
|
11
|
+
throw new ValidationError('AMMBid: Account is required and must be a valid XRPL account address');
|
|
12
|
+
}
|
|
13
|
+
// ── Asset ── required, must be a valid Currency (XRP / IOU / MPT).
|
|
14
|
+
if (props.Asset === undefined) {
|
|
15
|
+
throw new ValidationError('AMMBid: missing field Asset');
|
|
16
|
+
}
|
|
17
|
+
if (!isCurrency(props.Asset)) {
|
|
18
|
+
throw new ValidationError('AMMBid: Asset must be a Currency (XRP, trust line, or MPT form)');
|
|
19
|
+
}
|
|
20
|
+
// ── Asset2 ── required, must be a valid Currency (XRP / IOU / MPT).
|
|
21
|
+
if (props.Asset2 === undefined) {
|
|
22
|
+
throw new ValidationError('AMMBid: missing field Asset2');
|
|
23
|
+
}
|
|
24
|
+
if (!isCurrency(props.Asset2)) {
|
|
25
|
+
throw new ValidationError('AMMBid: Asset2 must be a Currency (XRP, trust line, or MPT form)');
|
|
26
|
+
}
|
|
27
|
+
// ── BidMin / BidMax ── when present, must be an IssuedCurrencyAmount
|
|
28
|
+
// (LP tokens are always issued currencies, never XRP and never MPT).
|
|
29
|
+
if (props.BidMin !== undefined && !isIssuedCurrencyAmount(props.BidMin)) {
|
|
30
|
+
throw new ValidationError('AMMBid: BidMin must be an IssuedCurrencyAmount (LP tokens are an issued currency, never XRP and never MPT)');
|
|
31
|
+
}
|
|
32
|
+
if (props.BidMax !== undefined && !isIssuedCurrencyAmount(props.BidMax)) {
|
|
33
|
+
throw new ValidationError('AMMBid: BidMax must be an IssuedCurrencyAmount (LP tokens are an issued currency, never XRP and never MPT)');
|
|
34
|
+
}
|
|
35
|
+
// ── AuthAccounts ── optional, but when present must be an array of
|
|
36
|
+
// up to MAX_AUTH_ACCOUNTS `{ AuthAccount: { Account } }` records,
|
|
37
|
+
// and must not include the sender's address.
|
|
38
|
+
if (props.AuthAccounts !== undefined) {
|
|
39
|
+
if (!Array.isArray(props.AuthAccounts)) {
|
|
40
|
+
throw new ValidationError('AMMBid: AuthAccounts must be an AuthAccount array');
|
|
41
|
+
}
|
|
42
|
+
if (props.AuthAccounts.length > MAX_AUTH_ACCOUNTS) {
|
|
43
|
+
throw new ValidationError(`AMMBid: AuthAccounts length must not be greater than ${MAX_AUTH_ACCOUNTS}`);
|
|
44
|
+
}
|
|
45
|
+
for (const entry of props.AuthAccounts) {
|
|
46
|
+
if (!isRecord(entry)) {
|
|
47
|
+
throw new ValidationError('AMMBid: invalid AuthAccounts');
|
|
48
|
+
}
|
|
49
|
+
const inner = entry['AuthAccount'];
|
|
50
|
+
if (!isRecord(inner)) {
|
|
51
|
+
throw new ValidationError('AMMBid: invalid AuthAccounts');
|
|
52
|
+
}
|
|
53
|
+
const acct = inner['Account'];
|
|
54
|
+
if (acct === undefined || acct === null || typeof acct !== 'string') {
|
|
55
|
+
throw new ValidationError('AMMBid: invalid AuthAccounts');
|
|
56
|
+
}
|
|
57
|
+
if (acct === props.Account) {
|
|
58
|
+
throw new ValidationError("AMMBid: AuthAccounts must not include sender's address");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return buildFrozenTx('AMMBid', props, {
|
|
63
|
+
validate() {
|
|
64
|
+
// Validated at construction.
|
|
65
|
+
},
|
|
66
|
+
toJSON() {
|
|
67
|
+
const json = {};
|
|
68
|
+
for (const k of Object.keys(this)) {
|
|
69
|
+
if (k === 'validate' || k === 'toJSON' || k === 'with')
|
|
70
|
+
continue;
|
|
71
|
+
const v = this[k];
|
|
72
|
+
if (v !== undefined)
|
|
73
|
+
json[k] = v;
|
|
74
|
+
}
|
|
75
|
+
return json;
|
|
76
|
+
},
|
|
77
|
+
with(overrides) {
|
|
78
|
+
return ammBid(mergeForWith(this, overrides));
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=amm-bid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-bid.js","sourceRoot":"","sources":["../../../src/fp/factories/amm-bid.ts"],"names":[],"mappings":"AA6FA,OAAO,EACL,SAAS,EACT,UAAU,EACV,sBAAsB,EACtB,QAAQ,EACR,QAAQ,GACT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE1D,wEAAwE;AAExE,mEAAmE;AACnE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AA2C5B,wEAAwE;AAExE,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,gEAAgE;IAChE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,eAAe,CACvB,sEAAsE,CACv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AAI,CAAC;QACd,CAAC;QACD,IAAI,CAAe,SAA+B;YAChD,OAAO,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QAC/C,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional AMMClawback factory — frozen-object style.
|
|
3
|
+
*
|
|
4
|
+
* Claw back tokens from a holder that has deposited the issuer's issued
|
|
5
|
+
* tokens into an AMM pool. The submitter (`Account`) must be the issuer
|
|
6
|
+
* of `Asset`. If `Amount` is omitted, all of the holder's tokens in
|
|
7
|
+
* the AMM pool are clawed back.
|
|
8
|
+
*
|
|
9
|
+
* Validation happens at construction; there is no way to construct an
|
|
10
|
+
* invalid tx.
|
|
11
|
+
*
|
|
12
|
+
* import { ammClawback } from 'xrplt/fp';
|
|
13
|
+
* const tx = ammClawback({
|
|
14
|
+
* Account,
|
|
15
|
+
* Holder,
|
|
16
|
+
* Asset: { currency: 'USD', issuer: Account },
|
|
17
|
+
* Asset2: { currency: 'XRP' },
|
|
18
|
+
* Amount: { currency: 'USD', issuer: Account, value: '1000' },
|
|
19
|
+
* Flags: AMMClawbackFlags.tfClawTwoAssets,
|
|
20
|
+
* });
|
|
21
|
+
* const j = tx.toJSON();
|
|
22
|
+
* const tx2 = tx.with({ Amount: { currency: 'USD', issuer: Account, value: '500' } });
|
|
23
|
+
*
|
|
24
|
+
* @see https://xrpl.org/docs/references/protocol/transactions/types/ammclawback
|
|
25
|
+
* @see https://github.com/XRPLF/xrpl.js/blob/main/packages/xrpl/src/models/transactions/AMMClawback.ts
|
|
26
|
+
* @see XLS-0073 §2.3 (https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0073-amm-clawback)
|
|
27
|
+
*
|
|
28
|
+
* ## Divergences
|
|
29
|
+
*
|
|
30
|
+
* Compared with `src/transactions/amm-clawback.ts`, this factory adds
|
|
31
|
+
* preclaim guards the class API skips. Each is cited to the canonical
|
|
32
|
+
* source.
|
|
33
|
+
*
|
|
34
|
+
* - **`Account` must be a valid XRPL classic (or X-) address.**
|
|
35
|
+
* The class inherits only `validateBaseTransaction`'s `isString(Account)`
|
|
36
|
+
* check, which lets `"not-an-address"` through.
|
|
37
|
+
* - Source: xrpl-dev-portal ammclawback.md, `Holder` row, Internal
|
|
38
|
+
* Type = `AccountID` (same encoding as `Account`).
|
|
39
|
+
*
|
|
40
|
+
* - **`Holder` must be a valid XRPL account** (format check).
|
|
41
|
+
* The class delegates to `isAccount`, which is fine — kept identical.
|
|
42
|
+
*
|
|
43
|
+
* - **`Holder` and `Asset.issuer` must be distinct.**
|
|
44
|
+
* The class only checks `isAccount(this.Holder)` and never compares
|
|
45
|
+
* it against `Asset.issuer`. The ledger rejects this with `temMALFORMED`
|
|
46
|
+
* ("Account is the same as the Holder" — docs use the word Account but
|
|
47
|
+
* the canonical check is against the asset issuer / submitter).
|
|
48
|
+
* - Source: xrpl.js `validateAMMClawback` lines 86–92, message
|
|
49
|
+
* `'AMMClawback: Holder and Asset.issuer must be distinct'`.
|
|
50
|
+
* - Source: xrpl-dev-portal ammclawback.md "Error Cases" table —
|
|
51
|
+
* `temMALFORMED` row.
|
|
52
|
+
*
|
|
53
|
+
* - **`Account` must equal `Asset.issuer`.**
|
|
54
|
+
* The class never compares them. Per the docs, this mismatches with
|
|
55
|
+
* `temMALFORMED` / `tecNO_PERMISSION`.
|
|
56
|
+
* - Source: xrpl.js `validateAMMClawback` lines 94–98, message
|
|
57
|
+
* `'AMMClawback: Account must be the same as Asset.issuer'`.
|
|
58
|
+
* - Source: xrpl-dev-portal ammclawback.md `Asset` row, Description:
|
|
59
|
+
* "The issuer must be the sender of this transaction."
|
|
60
|
+
* - Source: XLS-0073 §2.3, `Asset` row: "Asset's issuer should match
|
|
61
|
+
* with `Account`. Otherwise, `temMALFORMED` will be returned."
|
|
62
|
+
*
|
|
63
|
+
* - **`Asset` must be an IOU (`{ currency, issuer }`), NOT XRP and NOT MPT.**
|
|
64
|
+
* The class types `Asset` as `{ currency: string; issuer?: string }`,
|
|
65
|
+
* so callers can pass `{ currency: 'XRP' }` and the class accepts it.
|
|
66
|
+
* The ledger rejects `Asset` as XRP with `temMALFORMED`.
|
|
67
|
+
* - Source: xrpl.js `validateAMMClawback` line 84,
|
|
68
|
+
* `validateRequiredField(tx, 'Asset', isIssuedCurrency)`.
|
|
69
|
+
* - Source: xrpl-dev-portal ammclawback.md "Error Cases" table —
|
|
70
|
+
* `temMALFORMED` row, third bullet: "or `Asset` is XRP."
|
|
71
|
+
* - Source: XLS-0073 §2.3, `Asset` row: `Asset` is the token the issuer
|
|
72
|
+
* wants to claw back — by construction an IOU (the issuer is named).
|
|
73
|
+
*
|
|
74
|
+
* - **`Asset2` must be a valid `Currency`** (XRP, trust line IOU, or MPT).
|
|
75
|
+
* The class types `Asset2` as `{ currency: string; issuer?: string }`
|
|
76
|
+
* and never validates the object shape; MPT form slips through.
|
|
77
|
+
* - Source: xrpl.js `validateAMMClawback` line 100,
|
|
78
|
+
* `validateRequiredField(tx, 'Asset2', isIssuedCurrency)`.
|
|
79
|
+
* - Source: xrpl-dev-portal ammclawback.md `Asset2` row, Description:
|
|
80
|
+
* "The asset can be XRP, a trust line token, or an MPT."
|
|
81
|
+
* - Source: XLS-0073 §2.3, `Asset2` row: paired token in the AMM pool.
|
|
82
|
+
*
|
|
83
|
+
* - **`Amount` must be an `IssuedCurrencyAmount` — NOT an XRP drops
|
|
84
|
+
* string, NOT an MPTAmount.** The class types `Amount?: Amount`
|
|
85
|
+
* which accepts all three forms. Per the docs / xrpl.js, `Amount` is
|
|
86
|
+
* strictly IOU.
|
|
87
|
+
* - Source: xrpl.js `validateAMMClawback` line 102,
|
|
88
|
+
* `validateOptionalField(tx, 'Amount', isIssuedCurrencyAmount)`.
|
|
89
|
+
* - Source: xrpl-dev-portal ammclawback.md `Amount` row, JSON Type
|
|
90
|
+
* `Currency Amount`, Internal Type `Amount` (IOU-only for clawback).
|
|
91
|
+
*
|
|
92
|
+
* - **`Amount.currency` must equal `Asset.currency`.**
|
|
93
|
+
* The class never compares them.
|
|
94
|
+
* - Source: xrpl.js `validateAMMClawback` lines 104–108.
|
|
95
|
+
* - Source: xrpl-dev-portal ammclawback.md "Error Cases" table —
|
|
96
|
+
* `temBAD_AMOUNT` row: "the `currency` and `issuer` subfields don't
|
|
97
|
+
* match between `Amount` and `Asset`."
|
|
98
|
+
*
|
|
99
|
+
* - **`Amount.issuer` must equal `Asset.issuer`.**
|
|
100
|
+
* The class never compares them.
|
|
101
|
+
* - Source: xrpl.js `validateAMMClawback` lines 110–114 (note: xrpl.js
|
|
102
|
+
* source has a typo in the error message, "Amount.issuer must match
|
|
103
|
+
* Amount.issuer" — we keep the obvious correct intent: must match
|
|
104
|
+
* `Asset.issuer`).
|
|
105
|
+
* - Source: xrpl-dev-portal ammclawback.md `Amount` row, Description:
|
|
106
|
+
* "The `currency` and `issuer` subfields should match the `Asset`
|
|
107
|
+
* subfields."
|
|
108
|
+
*
|
|
109
|
+
* - **`Amount.value` must be a positive base-10 integer string.**
|
|
110
|
+
* The class delegates to `isAmount` which only checks shape; the docs
|
|
111
|
+
* say `Amount.value <= 0 → temBAD_AMOUNT`.
|
|
112
|
+
* - Source: xrpl-dev-portal ammclawback.md "Error Cases" table —
|
|
113
|
+
* `temBAD_AMOUNT` row: "the `Amount` field ... is less than or equal
|
|
114
|
+
* to 0".
|
|
115
|
+
* - Source: xrpl.org generic Amount spec
|
|
116
|
+
* (basic-data-types#specifying-currency-amounts).
|
|
117
|
+
*
|
|
118
|
+
* - **IssuedCurrencyAmount `currency` and `issuer` shape are validated**
|
|
119
|
+
* (3-char ASCII or 40-char hex `currency`; `issuer` must be a valid
|
|
120
|
+
* XRPL account). The class only checks `isAmount`, which does not
|
|
121
|
+
* enforce those sub-fields.
|
|
122
|
+
* - Source: xrpl-dev-portal basic-data-types#specifying-currency-amounts.
|
|
123
|
+
*
|
|
124
|
+
* - **`Flags` is restricted to 0 or `tfClawTwoAssets` (0x00000001).**
|
|
125
|
+
* The class inherits `Flags` from the parent and never inspects it.
|
|
126
|
+
* The ledger rejects other bit values with `temINVALID_FLAG`.
|
|
127
|
+
* - Source: xrpl-dev-portal ammclawback.md "AMMClawback Flags" section
|
|
128
|
+
* (only `tfClawTwoAssets` defined) + "Error Cases" table —
|
|
129
|
+
* `temINVALID_FLAG` row: "if you try enabling flags besides
|
|
130
|
+
* `tfClawTwoAssets`."
|
|
131
|
+
*/
|
|
132
|
+
import type { IssuedCurrency, IssuedCurrencyAmount, Currency } from '../../types/amounts.js';
|
|
133
|
+
import type { ClawbackFlagsInterface } from '../../types/flags.js';
|
|
134
|
+
export interface AmmClawbackProps {
|
|
135
|
+
/** The issuer submitting the clawback (must equal `Asset.issuer`). */
|
|
136
|
+
Account: string;
|
|
137
|
+
/** The holder whose tokens will be clawed back from the AMM pool. */
|
|
138
|
+
Holder: string;
|
|
139
|
+
/**
|
|
140
|
+
* The asset being clawed back — must be an IOU the submitter issued.
|
|
141
|
+
* NOT the XRP form, NOT an MPT.
|
|
142
|
+
*/
|
|
143
|
+
Asset: IssuedCurrency;
|
|
144
|
+
/**
|
|
145
|
+
* The other asset in the AMM pool. Can be XRP, an IOU, or an MPT.
|
|
146
|
+
*/
|
|
147
|
+
Asset2: Currency;
|
|
148
|
+
/**
|
|
149
|
+
* Optional maximum amount to claw back (IssuedCurrencyAmount; NOT
|
|
150
|
+
* XRP drops, NOT MPT). If omitted, all the holder's tokens are
|
|
151
|
+
* clawed back. When present, `currency`/`issuer` must match `Asset`.
|
|
152
|
+
*/
|
|
153
|
+
Amount?: IssuedCurrencyAmount | undefined;
|
|
154
|
+
/** Bit-flags: only `tfClawTwoAssets` (0x00000001) is defined. */
|
|
155
|
+
Flags?: number | ClawbackFlagsInterface | undefined;
|
|
156
|
+
Fee?: string | undefined;
|
|
157
|
+
Sequence?: number | undefined;
|
|
158
|
+
}
|
|
159
|
+
export interface AmmClawback extends Readonly<AmmClawbackProps> {
|
|
160
|
+
readonly TransactionType: 'AMMClawback';
|
|
161
|
+
validate(): void;
|
|
162
|
+
toJSON(): Record<string, unknown>;
|
|
163
|
+
with(overrides: Partial<AmmClawbackProps>): AmmClawback;
|
|
164
|
+
}
|
|
165
|
+
export declare function ammClawback(props: AmmClawbackProps): AmmClawback;
|
|
166
|
+
//# sourceMappingURL=amm-clawback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-clawback.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/amm-clawback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAkCnE,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAC;IACtB;;OAEG;IACH,MAAM,EAAE,QAAQ,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC1C,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAAC;IACpD,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,WAAY,SAAQ,QAAQ,CAAC,gBAAgB,CAAC;IAC7D,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;IACxC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,WAAW,CAAC;CACzD;AA4BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CA+IhE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { isAccount, isCurrency, isHex, isIssuedCurrencyAmount, isString, } from '../../validation/helpers.js';
|
|
2
|
+
import { ValidationError } from '../../errors.js';
|
|
3
|
+
import { buildFrozenTx, mergeForWith, require } from '../shape.js';
|
|
4
|
+
// ─── Spec constants ──────────────────────────────────────────────────
|
|
5
|
+
// Only AMMClawback-specific bit flag defined by the protocol.
|
|
6
|
+
// xrpl-dev-portal ammclawback.md "AMMClawback Flags" section.
|
|
7
|
+
// tfClawTwoAssets is 0x00000001 (matches xrpl.js AMMClawbackFlags enum
|
|
8
|
+
// and the project's src/types/flags.ts ClawbackFlags enum).
|
|
9
|
+
const TF_CLAW_TWO_ASSETS = 0x00000001;
|
|
10
|
+
// Global transaction flags (NonFungibleTokensV1_1 etc.) — also legal,
|
|
11
|
+
// per xrpl.js `GlobalFlagsInterface` / base transaction semantics.
|
|
12
|
+
const TF_INNER_BATCH = 0x40000000;
|
|
13
|
+
const TF_BATCH = 0x80000000;
|
|
14
|
+
// Combined mask: only tfClawTwoAssets + the two global batch flags are
|
|
15
|
+
// legal. Anything else triggers `temINVALID_FLAG`.
|
|
16
|
+
const LEGAL_AMM_CLAWBACK_FLAGS_MASK = TF_CLAW_TWO_ASSETS | TF_BATCH | TF_INNER_BATCH;
|
|
17
|
+
// Currency codes are either 3 ASCII characters or 40 hex characters.
|
|
18
|
+
const CURRENCY_ASCII_LENGTH = 3;
|
|
19
|
+
const CURRENCY_HEX_LENGTH = 40;
|
|
20
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* XRPLNumber: a non-negative base-10 integer string. Matches the policy
|
|
23
|
+
* used across other factories (ammCreate, vaultClawback, loanSet).
|
|
24
|
+
*/
|
|
25
|
+
function isXrplNumber(value) {
|
|
26
|
+
return isString(value) && /^[0-9]+$/u.test(value);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extract the numeric bitmask from `Flags` regardless of whether the
|
|
30
|
+
* caller passed a numeric value or a boolean `ClawbackFlagsInterface`.
|
|
31
|
+
*/
|
|
32
|
+
function flagsToNumber(flags) {
|
|
33
|
+
if (flags === undefined)
|
|
34
|
+
return 0;
|
|
35
|
+
if (typeof flags === 'number')
|
|
36
|
+
return flags;
|
|
37
|
+
let n = 0;
|
|
38
|
+
if (flags.tfClawTwoAssets)
|
|
39
|
+
n |= TF_CLAW_TWO_ASSETS;
|
|
40
|
+
return n;
|
|
41
|
+
}
|
|
42
|
+
// ─── Factory ─────────────────────────────────────────────────────────
|
|
43
|
+
export function ammClawback(props) {
|
|
44
|
+
// ── Account ── required, valid XRPL classic / X-address.
|
|
45
|
+
require(props.Account, 'AMMClawback: Account is required', isAccount);
|
|
46
|
+
// ── Holder ── required, valid XRPL classic / X-address.
|
|
47
|
+
require(props.Holder, 'AMMClawback: Holder is required', isAccount);
|
|
48
|
+
// ── Asset ── required, IOU form (`{ currency, issuer }`).
|
|
49
|
+
// xrpl.js uses `isIssuedCurrency` which would also accept XRP form,
|
|
50
|
+
// but per docs (temMALFORMED if Asset is XRP) we explicitly reject it.
|
|
51
|
+
if (props.Asset === undefined) {
|
|
52
|
+
throw new ValidationError('AMMClawback: missing field Asset');
|
|
53
|
+
}
|
|
54
|
+
if (!isString(props.Asset.currency) ||
|
|
55
|
+
isString(props.Asset.mpt_issuance_id) ||
|
|
56
|
+
props.Asset.currency === 'XRP') {
|
|
57
|
+
throw new ValidationError('AMMClawback: Asset must be an IOU (currency + issuer; NOT XRP, NOT MPT)');
|
|
58
|
+
}
|
|
59
|
+
if (!isString(props.Asset.issuer)) {
|
|
60
|
+
throw new ValidationError('AMMClawback: Asset.issuer is required (Asset must be an IOU)');
|
|
61
|
+
}
|
|
62
|
+
// Asset currency shape: 3 ASCII or 40 hex characters.
|
|
63
|
+
const assetCcy = props.Asset.currency;
|
|
64
|
+
if (assetCcy.length !== CURRENCY_ASCII_LENGTH &&
|
|
65
|
+
assetCcy.length !== CURRENCY_HEX_LENGTH) {
|
|
66
|
+
throw new ValidationError(`AMMClawback: Asset.currency must be ${CURRENCY_ASCII_LENGTH} ASCII characters or ${CURRENCY_HEX_LENGTH} hex characters (actual: ${assetCcy.length})`);
|
|
67
|
+
}
|
|
68
|
+
if (assetCcy.length === CURRENCY_HEX_LENGTH && !isHex(assetCcy)) {
|
|
69
|
+
throw new ValidationError('AMMClawback: Asset.currency (40-char form) must be hex');
|
|
70
|
+
}
|
|
71
|
+
// Asset.issuer must be a valid XRPL account.
|
|
72
|
+
if (!isAccount(props.Asset.issuer)) {
|
|
73
|
+
throw new ValidationError('AMMClawback: Asset.issuer must be a valid XRPL account address');
|
|
74
|
+
}
|
|
75
|
+
// ── Holder ≠ Asset.issuer ── (xrpl.js `validateAMMClawback` lines 86–92).
|
|
76
|
+
if (props.Holder === props.Asset.issuer) {
|
|
77
|
+
throw new ValidationError('AMMClawback: Holder and Asset.issuer must be distinct');
|
|
78
|
+
}
|
|
79
|
+
// ── Account === Asset.issuer ── (xrpl.js lines 94–98).
|
|
80
|
+
if (props.Account !== props.Asset.issuer) {
|
|
81
|
+
throw new ValidationError('AMMClawback: Account must be the same as Asset.issuer');
|
|
82
|
+
}
|
|
83
|
+
// ── Asset2 ── required, valid Currency (XRP, IOU, or MPT).
|
|
84
|
+
if (props.Asset2 === undefined) {
|
|
85
|
+
throw new ValidationError('AMMClawback: missing field Asset2');
|
|
86
|
+
}
|
|
87
|
+
if (!isCurrency(props.Asset2)) {
|
|
88
|
+
throw new ValidationError('AMMClawback: Asset2 must be a valid Currency (XRP, trust line, or MPT form)');
|
|
89
|
+
}
|
|
90
|
+
// ── Amount ── optional; when present, must be an IssuedCurrencyAmount
|
|
91
|
+
// (NOT XRP drops string, NOT MPT).
|
|
92
|
+
if (props.Amount !== undefined) {
|
|
93
|
+
if (!isIssuedCurrencyAmount(props.Amount)) {
|
|
94
|
+
throw new ValidationError('AMMClawback: Amount must be an IssuedCurrencyAmount (NOT XRP drops, NOT MPT)');
|
|
95
|
+
}
|
|
96
|
+
// Amount.currency === Asset.currency.
|
|
97
|
+
if (props.Amount.currency !== props.Asset.currency) {
|
|
98
|
+
throw new ValidationError('AMMClawback: Amount.currency must match Asset.currency');
|
|
99
|
+
}
|
|
100
|
+
// Amount.issuer === Asset.issuer.
|
|
101
|
+
if (props.Amount.issuer !== props.Asset.issuer) {
|
|
102
|
+
throw new ValidationError('AMMClawback: Amount.issuer must match Asset.issuer');
|
|
103
|
+
}
|
|
104
|
+
// Amount sub-field validation (issuer is a valid account).
|
|
105
|
+
if (!isAccount(props.Amount.issuer)) {
|
|
106
|
+
throw new ValidationError('AMMClawback: Amount.issuer must be a valid XRPL account address');
|
|
107
|
+
}
|
|
108
|
+
// Amount.value must be a positive base-10 integer string.
|
|
109
|
+
if (!isXrplNumber(props.Amount.value)) {
|
|
110
|
+
throw new ValidationError('AMMClawback: Amount.value must be a non-negative base-10 integer string');
|
|
111
|
+
}
|
|
112
|
+
if (props.Amount.value === '0') {
|
|
113
|
+
throw new ValidationError('AMMClawback: Amount must be a positive amount (got "0")');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// ── Flags ── only tfClawTwoAssets (+ global batch flags) are legal.
|
|
117
|
+
// (xrpl-dev-portal ammclawback.md "AMMClawback Flags" + temINVALID_FLAG row.)
|
|
118
|
+
const numericFlags = flagsToNumber(props.Flags);
|
|
119
|
+
const unknownBits = numericFlags & ~LEGAL_AMM_CLAWBACK_FLAGS_MASK;
|
|
120
|
+
if (unknownBits !== 0) {
|
|
121
|
+
throw new ValidationError(`AMMClawback: Flags may only set tfClawTwoAssets (0x${TF_CLAW_TWO_ASSETS.toString(16)}); unknown bit(s): 0x${unknownBits.toString(16)}`);
|
|
122
|
+
}
|
|
123
|
+
return buildFrozenTx('AMMClawback', props, {
|
|
124
|
+
validate() {
|
|
125
|
+
// Validated at construction.
|
|
126
|
+
},
|
|
127
|
+
toJSON() {
|
|
128
|
+
const json = {};
|
|
129
|
+
for (const k of Object.keys(this)) {
|
|
130
|
+
if (k === 'validate' || k === 'toJSON' || k === 'with')
|
|
131
|
+
continue;
|
|
132
|
+
const v = this[k];
|
|
133
|
+
if (v !== undefined)
|
|
134
|
+
json[k] = v;
|
|
135
|
+
}
|
|
136
|
+
return json;
|
|
137
|
+
},
|
|
138
|
+
with(overrides) {
|
|
139
|
+
return ammClawback(mergeForWith(this, overrides));
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=amm-clawback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-clawback.js","sourceRoot":"","sources":["../../../src/fp/factories/amm-clawback.ts"],"names":[],"mappings":"AAqIA,OAAO,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,sBAAsB,EACtB,QAAQ,GACT,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEnE,wEAAwE;AAExE,8DAA8D;AAC9D,8DAA8D;AAC9D,uEAAuE;AACvE,4DAA4D;AAC5D,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAEtC,sEAAsE;AACtE,mEAAmE;AACnE,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B,uEAAuE;AACvE,mDAAmD;AACnD,MAAM,6BAA6B,GAAG,kBAAkB,GAAG,QAAQ,GAAG,cAAc,CAAC;AAErF,qEAAqE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AAM,IAAI,eAAe,CACvB,sDAAsD,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,wBAAwB,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CACxI,CAAC;IACJ,CAAC;IAED,OAAO,aAAa,CAClB,aAAa,EACb,KAAK,EACL;QACE,QAAQ;YACN,6BAA6B;QAC/B,CAAC;QACD,MAAM;YACJ,MAAM,IAAI,GAA4B,EAAE,CAAC;YACzC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,MAAM;oBAAE,SAAS;gBACjE,MAAM,CAAC,GAAI,IAA2C,CAAC,CAAC,CAAC,CAAC;gBAC1D,IAAI,CAAC,KAAK,SAAS;oBAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACnC,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,CAAoB,SAAoC;YAC1D,OAAO,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QACpD,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional AMMCreate factory — frozen-object style.
|
|
3
|
+
*
|
|
4
|
+
* Creates a new Automated Market Maker (AMM) instance for trading a pair
|
|
5
|
+
* of assets (XRP, IOU, or MPT). The class-based equivalent requires a
|
|
6
|
+
* separate `.validate()` call after construction; this factory validates
|
|
7
|
+
* at construction so an invalid tx can never exist.
|
|
8
|
+
*
|
|
9
|
+
* import { ammCreate } from 'xrplt/fp';
|
|
10
|
+
* const tx = ammCreate({ Account, Amount, Amount2, TradingFee });
|
|
11
|
+
* const j = tx.toJSON();
|
|
12
|
+
* const tx2 = tx.with({ TradingFee: 250 });
|
|
13
|
+
*
|
|
14
|
+
* @see https://xrpl.org/docs/references/protocol/transactions/types/ammcreate
|
|
15
|
+
* @see https://github.com/XRPLF/xrpl.js/blob/main/packages/xrpl/src/models/transactions/AMMCreate.ts
|
|
16
|
+
* @see XLS-0030 §2.2 (https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0030-automated-market-maker)
|
|
17
|
+
*
|
|
18
|
+
* ## Divergences
|
|
19
|
+
*
|
|
20
|
+
* Compared with `src/transactions/amm-create.ts`, this factory adds
|
|
21
|
+
* guards the class skips:
|
|
22
|
+
*
|
|
23
|
+
* - **Account must be a valid XRPL classic (or X-) address**. The class
|
|
24
|
+
* inherits only `validateBaseTransaction`'s `isString(Account)` check.
|
|
25
|
+
* - Source: xrpl-dev-portal basic-data-types (AccountID is a classic
|
|
26
|
+
* address or X-address).
|
|
27
|
+
*
|
|
28
|
+
* - **Each Amount must be strictly positive** (per the docs: "This must
|
|
29
|
+
* be a positive amount"). The class only checks shape via `isAmount`,
|
|
30
|
+
* which does not check numeric well-formedness or sign.
|
|
31
|
+
* - Source: xrpl-dev-portal ammcreate.md, Fields table — `Amount` and
|
|
32
|
+
* `Amount2` rows, both Description columns end with "This must be a
|
|
33
|
+
* positive amount."
|
|
34
|
+
* - Source: XLS-0030 §2.2.1 (both Amount and Amount2 are required
|
|
35
|
+
* currency amounts that must be positive).
|
|
36
|
+
*
|
|
37
|
+
* - **Amount `value` must be a non-negative base-10 integer string** (the
|
|
38
|
+
* canonical XRPL Number representation). The class does not check this.
|
|
39
|
+
* - Source: xrpl.org generic Amount spec
|
|
40
|
+
* (https://xrpl.org/docs/references/protocol/data-types/basic-data-types#specifying-currency-amounts).
|
|
41
|
+
*
|
|
42
|
+
* - **IssuedCurrencyAmount `currency` and `issuer` shape are validated**
|
|
43
|
+
* (3-char ASCII or 40-char hex `currency`; `issuer` must be a valid
|
|
44
|
+
* XRPL account). The class delegates to `isAmount`, which only checks
|
|
45
|
+
* that the keys exist as strings.
|
|
46
|
+
* - Source: xrpl-dev-portal basic-data-types#specifying-currency-amounts.
|
|
47
|
+
*
|
|
48
|
+
* - **MPTAmount `mpt_issuance_id` must be a 24–48-character hex string**
|
|
49
|
+
* (192-bit issuance ID, hex-encoded). The class only checks key
|
|
50
|
+
* presence.
|
|
51
|
+
* - Source: XLS-0033 Multi-Purpose Tokens (mpt_issuance_id is a 192-bit
|
|
52
|
+
* uint; we accept 24–48 hex chars to leave slack for future
|
|
53
|
+
* widenings / leading-zero encoders).
|
|
54
|
+
*
|
|
55
|
+
* - **TradingFee must be an integer** (XLS-0030 §2.2.1 declares the
|
|
56
|
+
* internal type as `UINT16`). The class accepts any number ≤ 1000,
|
|
57
|
+
* including 1.5, etc.
|
|
58
|
+
* - Source: XLS-0030 §2.2.1, Fields table, `TradingFee` row, Internal
|
|
59
|
+
* Type = `UINT16`.
|
|
60
|
+
*
|
|
61
|
+
* - **At most one of Amount and Amount2 can be XRP**. The class does not
|
|
62
|
+
* enforce this cross-field invariant.
|
|
63
|
+
* - Source: xrpl-dev-portal ammcreate.md prose line immediately after
|
|
64
|
+
* the Fields table: "at most one of them can be XRP."
|
|
65
|
+
*/
|
|
66
|
+
import type { Amount } from '../../types/amounts.js';
|
|
67
|
+
export interface AmmCreateProps {
|
|
68
|
+
/** The unique address of the transaction sender (LP / pool creator). */
|
|
69
|
+
Account: string;
|
|
70
|
+
/** The first of the two assets to fund this AMM with (positive). */
|
|
71
|
+
Amount: Amount;
|
|
72
|
+
/** The second of the two assets to fund this AMM with (positive). */
|
|
73
|
+
Amount2: Amount;
|
|
74
|
+
/**
|
|
75
|
+
* The fee to charge for trades against this AMM, in 1/100,000 units
|
|
76
|
+
* (1 = 0.001%). Must be in [0, 1000] inclusive. UINT16 integer.
|
|
77
|
+
*/
|
|
78
|
+
TradingFee: number;
|
|
79
|
+
/** Bit-flags for this transaction (AMMCreate defines no flags). */
|
|
80
|
+
Flags?: number | undefined;
|
|
81
|
+
Fee?: string | undefined;
|
|
82
|
+
Sequence?: number | undefined;
|
|
83
|
+
}
|
|
84
|
+
export interface AmmCreate extends Readonly<AmmCreateProps> {
|
|
85
|
+
readonly TransactionType: 'AMMCreate';
|
|
86
|
+
validate(): void;
|
|
87
|
+
toJSON(): Record<string, unknown>;
|
|
88
|
+
with(overrides: Partial<AmmCreateProps>): AmmCreate;
|
|
89
|
+
}
|
|
90
|
+
export declare function ammCreate(props: AmmCreateProps): AmmCreate;
|
|
91
|
+
//# sourceMappingURL=amm-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amm-create.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/amm-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA+BrD,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,SAAU,SAAQ,QAAQ,CAAC,cAAc,CAAC;IACzD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC;IACtC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;CACrD;AAoHD,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAyD1D"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { isAccount, isAmount, isHex, isIssuedCurrencyAmount, isMPTAmount, isNumber, isString, } from '../../validation/helpers.js';
|
|
2
|
+
import { ValidationError } from '../../errors.js';
|
|
3
|
+
import { buildFrozenTx, mergeForWith, require } from '../shape.js';
|
|
4
|
+
// ─── Spec constants ──────────────────────────────────────────────────
|
|
5
|
+
// TradingFee is a UINT16 with a ledger-enforced range of 0–1000
|
|
6
|
+
// (0%–1%). (XLS-0030 §2.2.1; xrpl.js AMM_MAX_TRADING_FEE.)
|
|
7
|
+
const AMM_MAX_TRADING_FEE = 1000;
|
|
8
|
+
// Currency codes are either 3 ASCII characters or 40 hex characters.
|
|
9
|
+
const CURRENCY_ASCII_LENGTH = 3;
|
|
10
|
+
const CURRENCY_HEX_LENGTH = 40;
|
|
11
|
+
// MPT issuance IDs are 192-bit, hex-encoded (≤ 48 chars). We accept
|
|
12
|
+
// 24–48 to leave slack for future widenings / leading-zero encoders.
|
|
13
|
+
// (XLS-0033; matches the policy used by vaultClawback.)
|
|
14
|
+
const MPT_ISSUANCE_ID_MIN = 24;
|
|
15
|
+
const MPT_ISSUANCE_ID_MAX = 48;
|
|
16
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* XRPLNumber: a non-negative base-10 integer string. Matches the policy
|
|
19
|
+
* used across other factories (loanSet, vaultCreate, vaultClawback).
|
|
20
|
+
*/
|
|
21
|
+
function isXrplNumber(value) {
|
|
22
|
+
return isString(value) && /^[0-9]+$/u.test(value);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Deep-validate an Amount that must be strictly > 0 (used for
|
|
26
|
+
* AMMCreate.Amount and Amount2).
|
|
27
|
+
*
|
|
28
|
+
* Performs:
|
|
29
|
+
* - shape check via `isAmount`
|
|
30
|
+
* - for IOU: currency length / hex check, issuer is a valid account,
|
|
31
|
+
* value is a positive base-10 integer string (rejects 0 and "-1")
|
|
32
|
+
* - for MPT: mpt_issuance_id length / hex check, value is a positive
|
|
33
|
+
* base-10 integer string
|
|
34
|
+
* - for XRP string: must be a positive base-10 integer string
|
|
35
|
+
*/
|
|
36
|
+
function validatePositiveAmount(amount, path) {
|
|
37
|
+
if (!isAmount(amount)) {
|
|
38
|
+
throw new ValidationError(`AMMCreate: ${path} must be a valid Amount (XRP string, IOU, or MPT form)`);
|
|
39
|
+
}
|
|
40
|
+
// XRP path: positive base-10 integer string.
|
|
41
|
+
if (isString(amount)) {
|
|
42
|
+
if (!isXrplNumber(amount)) {
|
|
43
|
+
throw new ValidationError(`AMMCreate: ${path} (XRP) must be a non-negative base-10 integer string`);
|
|
44
|
+
}
|
|
45
|
+
if (amount === '0') {
|
|
46
|
+
throw new ValidationError(`AMMCreate: ${path} must be a positive amount (got "0")`);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// IOU path.
|
|
51
|
+
if (isIssuedCurrencyAmount(amount)) {
|
|
52
|
+
// currency length
|
|
53
|
+
const ccy = amount.currency;
|
|
54
|
+
if (ccy.length !== CURRENCY_ASCII_LENGTH &&
|
|
55
|
+
ccy.length !== CURRENCY_HEX_LENGTH) {
|
|
56
|
+
throw new ValidationError(`AMMCreate: ${path}.currency must be ${CURRENCY_ASCII_LENGTH} ASCII characters or ${CURRENCY_HEX_LENGTH} hex characters (actual: ${ccy.length})`);
|
|
57
|
+
}
|
|
58
|
+
if (ccy.length === CURRENCY_HEX_LENGTH && !isHex(ccy)) {
|
|
59
|
+
throw new ValidationError(`AMMCreate: ${path}.currency (40-char form) must be hex`);
|
|
60
|
+
}
|
|
61
|
+
// issuer
|
|
62
|
+
if (!isAccount(amount.issuer)) {
|
|
63
|
+
throw new ValidationError(`AMMCreate: ${path}.issuer must be a valid XRPL account address`);
|
|
64
|
+
}
|
|
65
|
+
// value: positive base-10 integer string
|
|
66
|
+
if (!isXrplNumber(amount.value)) {
|
|
67
|
+
throw new ValidationError(`AMMCreate: ${path}.value must be a non-negative base-10 integer string`);
|
|
68
|
+
}
|
|
69
|
+
if (amount.value === '0') {
|
|
70
|
+
throw new ValidationError(`AMMCreate: ${path} must be a positive amount (got "0")`);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// MPT path.
|
|
75
|
+
if (isMPTAmount(amount)) {
|
|
76
|
+
const mptid = amount.mpt_issuance_id;
|
|
77
|
+
if (mptid.length < MPT_ISSUANCE_ID_MIN ||
|
|
78
|
+
mptid.length > MPT_ISSUANCE_ID_MAX ||
|
|
79
|
+
!isHex(mptid)) {
|
|
80
|
+
throw new ValidationError(`AMMCreate: ${path}.mpt_issuance_id must be a ${MPT_ISSUANCE_ID_MIN}-${MPT_ISSUANCE_ID_MAX} character hex string`);
|
|
81
|
+
}
|
|
82
|
+
if (!isXrplNumber(amount.value)) {
|
|
83
|
+
throw new ValidationError(`AMMCreate: ${path}.value must be a non-negative base-10 integer string`);
|
|
84
|
+
}
|
|
85
|
+
if (amount.value === '0') {
|
|
86
|
+
throw new ValidationError(`AMMCreate: ${path} must be a positive amount (got "0")`);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// isAmount returned true but we didn't classify it — defensive.
|
|
91
|
+
throw new ValidationError(`AMMCreate: ${path} must be a valid Amount (XRP string, IOU, or MPT form)`);
|
|
92
|
+
}
|
|
93
|
+
// ─── Factory ─────────────────────────────────────────────────────────
|
|
94
|
+
export function ammCreate(props) {
|
|
95
|
+
// ── Account ── required, must be a valid XRPL classic / X-address.
|
|
96
|
+
require(props.Account, 'AMMCreate: Account is required', isAccount);
|
|
97
|
+
// ── Amount / Amount2 ── required, must be a strictly positive Amount.
|
|
98
|
+
validatePositiveAmount(props.Amount, 'Amount');
|
|
99
|
+
validatePositiveAmount(props.Amount2, 'Amount2');
|
|
100
|
+
// ── TradingFee ── required, integer, 0–1000 inclusive.
|
|
101
|
+
if (props.TradingFee === undefined || props.TradingFee === null) {
|
|
102
|
+
throw new ValidationError('AMMCreate: TradingFee is required');
|
|
103
|
+
}
|
|
104
|
+
if (!isNumber(props.TradingFee)) {
|
|
105
|
+
throw new ValidationError('AMMCreate: TradingFee must be a number');
|
|
106
|
+
}
|
|
107
|
+
if (!Number.isInteger(props.TradingFee)) {
|
|
108
|
+
throw new ValidationError('AMMCreate: TradingFee must be an integer (UINT16)');
|
|
109
|
+
}
|
|
110
|
+
if (props.TradingFee < 0 || props.TradingFee > AMM_MAX_TRADING_FEE) {
|
|
111
|
+
throw new ValidationError(`AMMCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE} inclusive (got ${props.TradingFee})`);
|
|
112
|
+
}
|
|
113
|
+
// ── Cross-field: at most one of Amount / Amount2 may be XRP.
|
|
114
|
+
// (xrpl-dev-portal ammcreate.md prose line: "at most one of them can be XRP.")
|
|
115
|
+
const a1IsXrp = isString(props.Amount);
|
|
116
|
+
const a2IsXrp = isString(props.Amount2);
|
|
117
|
+
if (a1IsXrp && a2IsXrp) {
|
|
118
|
+
throw new ValidationError('AMMCreate: at most one of Amount and Amount2 can be XRP');
|
|
119
|
+
}
|
|
120
|
+
return buildFrozenTx('AMMCreate', props, {
|
|
121
|
+
validate() {
|
|
122
|
+
// Validated at construction.
|
|
123
|
+
},
|
|
124
|
+
toJSON() {
|
|
125
|
+
const json = {};
|
|
126
|
+
for (const k of Object.keys(this)) {
|
|
127
|
+
if (k === 'validate' || k === 'toJSON' || k === 'with')
|
|
128
|
+
continue;
|
|
129
|
+
const v = this[k];
|
|
130
|
+
if (v !== undefined)
|
|
131
|
+
json[k] = v;
|
|
132
|
+
}
|
|
133
|
+
return json;
|
|
134
|
+
},
|
|
135
|
+
with(overrides) {
|
|
136
|
+
return ammCreate(mergeForWith(this, overrides));
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=amm-create.js.map
|