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,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional SponsorshipTransfer factory — frozen-object style.
|
|
3
|
+
*
|
|
4
|
+
* Create, transfer, or end reserve sponsorship for a ledger object or
|
|
5
|
+
* account. Operates in one of three mutually-exclusive modes, selected by
|
|
6
|
+
* exactly one of:
|
|
7
|
+
* - `tfSponsorshipEnd` (0x00010000)
|
|
8
|
+
* - `tfSponsorshipCreate` (0x00020000)
|
|
9
|
+
* - `tfSponsorshipReassign` (0x00040000)
|
|
10
|
+
*
|
|
11
|
+
* import { sponsorshipTransfer } from 'xrplt/fp';
|
|
12
|
+
* const tx = sponsorshipTransfer({
|
|
13
|
+
* Account,
|
|
14
|
+
* Flags: 0x00020000, // tfSponsorshipCreate
|
|
15
|
+
* ObjectID: '...64 hex...',
|
|
16
|
+
* Sponsor: 'rNEW_SPONSOR',
|
|
17
|
+
* SponsorFlags: 0x00000002, // spfSponsorReserve
|
|
18
|
+
* });
|
|
19
|
+
* const tx2 = tx.with({ Flags: 0x00010000 }); // tfSponsorshipEnd
|
|
20
|
+
* const j = tx.toJSON();
|
|
21
|
+
*
|
|
22
|
+
* Affected amendments:
|
|
23
|
+
* - `Sponsor` (base SponsorshipTransfer + the three sponsorship scenarios)
|
|
24
|
+
*
|
|
25
|
+
* @see https://xrpl.org/docs/references/protocol/transactions/types/sponsortransfer
|
|
26
|
+
* @see xrpl.js `validateSponsorshipTransfer`
|
|
27
|
+
* (`~/.mavis/docs.local/xrpl.js/repo/packages/xrpl/src/models/
|
|
28
|
+
* transactions/sponsorshipTransfer.ts`)
|
|
29
|
+
*
|
|
30
|
+
* ## Divergences
|
|
31
|
+
*
|
|
32
|
+
* The factory enforces eight preclaim rules that the class API
|
|
33
|
+
* (`src/transactions/sponsorship-transfer.ts`) skips. Each one is mandated
|
|
34
|
+
* by the Sponsor amendment / `validateSponsorshipTransfer` /
|
|
35
|
+
* `sponsorshiptransfer.md`.
|
|
36
|
+
*
|
|
37
|
+
* 1. `ObjectID`, when present, must be a 64-character hex string
|
|
38
|
+
* (HASH256 form).
|
|
39
|
+
* Source: xrpl.js `validateSponsorshipTransfer` (lines 141–145) —
|
|
40
|
+
* "ObjectID should be a 64-character hex string (ledger object ID)".
|
|
41
|
+
* The class only checks `isString(ObjectID)` and accepts any string.
|
|
42
|
+
*
|
|
43
|
+
* 2. `Sponsor` is REQUIRED for `tfSponsorshipCreate` and
|
|
44
|
+
* `tfSponsorshipReassign`; the field must NOT be present for
|
|
45
|
+
* `tfSponsorshipEnd`.
|
|
46
|
+
* Source: xrpl-dev-portal `sponsorshiptransfer.md` Error Cases —
|
|
47
|
+
* `temMALFORMED`: "The `Sponsor` field is missing when creating or
|
|
48
|
+
* reassigning a sponsorship." / "The `Sponsor` field is present when
|
|
49
|
+
* ending a sponsorship." xrpl.js lines 149–163 enforce both.
|
|
50
|
+
* The class does not accept the `Sponsor` field at all.
|
|
51
|
+
*
|
|
52
|
+
* 3. `Sponsor` must be a valid XRPL account address AND must not equal
|
|
53
|
+
* `Account`.
|
|
54
|
+
* Source: xrpl.js lines 166–183 (validates with `isAccount` and
|
|
55
|
+
* `areAddressesEqual(Account, Sponsor)`). The class does not check
|
|
56
|
+
* this because it doesn't accept the field.
|
|
57
|
+
*
|
|
58
|
+
* 4. `SponsorFlags` is REQUIRED for Create/Reassign and must have the
|
|
59
|
+
* `spfSponsorReserve` (0x00000002) bit set; the field must NOT be
|
|
60
|
+
* present for `tfSponsorshipEnd`.
|
|
61
|
+
* Source: xrpl-dev-portal `sponsorshiptransfer.md` Create / Reassign
|
|
62
|
+
* tabs — "Provide the `Sponsor` field with the
|
|
63
|
+
* `SponsorFlags.spfSponsorReserve` flag." End tab — "Do not include
|
|
64
|
+
* the `Sponsor` and `SponsorFlags` fields." xrpl.js lines 187–199
|
|
65
|
+
* enforce the required-bit. The class does not accept the field at
|
|
66
|
+
* all.
|
|
67
|
+
*
|
|
68
|
+
* 5. `SponsorSignature` is REQUIRED for **account-level** Create/Reassign
|
|
69
|
+
* (i.e. when `ObjectID` is omitted); optional (but allowed) for
|
|
70
|
+
* object-level Create/Reassign.
|
|
71
|
+
* Source: xrpl-dev-portal `sponsorshiptransfer.md` Create / Reassign
|
|
72
|
+
* tabs — "Include the `SponsorSignature` when sponsoring an account.
|
|
73
|
+
* This is optional when sponsoring an object." xrpl.js lines
|
|
74
|
+
* 205–212 enforce this. The class does not accept the field at all.
|
|
75
|
+
*
|
|
76
|
+
* 6. `SponsorSignature`, when present, must be a well-formed object
|
|
77
|
+
* with EITHER single-sign fields (`SigningPubKey` + `TxnSignature`)
|
|
78
|
+
* OR a `Signers` array (multi-sign), but not both.
|
|
79
|
+
* Source: xrpl.js `SponsorSignature` type
|
|
80
|
+
* (`packages/xrpl/src/models/common/index.ts` lines 57–69) and
|
|
81
|
+
* rippled's `STObject` deserialization rules. The class doesn't
|
|
82
|
+
* validate shape because it doesn't accept the field.
|
|
83
|
+
*
|
|
84
|
+
* 7. `Sponsee` must not equal `Account`.
|
|
85
|
+
* Source: xrpl.js lines 231–235 (uses `areAddressesEqual`).
|
|
86
|
+
* The class does not check identity.
|
|
87
|
+
*
|
|
88
|
+
* 8. Both numeric and boolean-map `Flags` forms are accepted (matching
|
|
89
|
+
* xrpl.js), and the two forms are normalised — but neither may carry
|
|
90
|
+
* any unknown mode bits. The class accepts the object form only and
|
|
91
|
+
* does not validate bit values against the three documented modes.
|
|
92
|
+
*
|
|
93
|
+
* Note: the factory is the **only** place that distinguishes "object-level
|
|
94
|
+
* sponsorship" (ObjectID present) from "account-level sponsorship"
|
|
95
|
+
* (ObjectID omitted) for the SponsorSignature-required check. The class
|
|
96
|
+
* lets you build a Create/Reassign tx with no ObjectID and no
|
|
97
|
+
* SponsorSignature, which the ledger rejects with `temMALFORMED`.
|
|
98
|
+
*/
|
|
99
|
+
import type { SponsorshipTransferFlagsInterface } from '../../types/flags.js';
|
|
100
|
+
/**
|
|
101
|
+
* Sponsor authorization signature. Mirrors the xrpl.js `SponsorSignature`
|
|
102
|
+
* discriminated union: either single-sign fields OR multi-sign Signers,
|
|
103
|
+
* but not both.
|
|
104
|
+
*
|
|
105
|
+
* The factory validates this shape locally; no need for the consumer to
|
|
106
|
+
* depend on xrpl.js for the type.
|
|
107
|
+
*/
|
|
108
|
+
export type SponsorSignatureProps = {
|
|
109
|
+
/** The sponsor's public key (for single-signing). */
|
|
110
|
+
SigningPubKey: string;
|
|
111
|
+
/** The sponsor's signature (for single-signing). */
|
|
112
|
+
TxnSignature: string;
|
|
113
|
+
Signers?: never;
|
|
114
|
+
} | {
|
|
115
|
+
SigningPubKey?: never;
|
|
116
|
+
TxnSignature?: never;
|
|
117
|
+
/** Array of sponsor signatures (for multi-signing). */
|
|
118
|
+
Signers: readonly {
|
|
119
|
+
readonly Signer: {
|
|
120
|
+
readonly Account: string;
|
|
121
|
+
readonly TxnSignature: string;
|
|
122
|
+
readonly SigningPubKey: string;
|
|
123
|
+
};
|
|
124
|
+
}[];
|
|
125
|
+
};
|
|
126
|
+
export interface SponsorshipTransferProps {
|
|
127
|
+
/** The unique address of the transaction sender (sponsee or sponsor). */
|
|
128
|
+
Account: string;
|
|
129
|
+
/**
|
|
130
|
+
* The mode flag. Must be exactly one of `tfSponsorshipEnd`,
|
|
131
|
+
* `tfSponsorshipCreate`, or `tfSponsorshipReassign`. Numeric or
|
|
132
|
+
* boolean-map form is accepted (canonical form is numeric).
|
|
133
|
+
*/
|
|
134
|
+
Flags?: number | SponsorshipTransferFlagsInterface | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* The ID of the ledger entry whose sponsorship is being changed.
|
|
137
|
+
* 64-char hex. Required when sponsoring / ending sponsorship for an
|
|
138
|
+
* object; omit for account-level sponsorship.
|
|
139
|
+
*/
|
|
140
|
+
ObjectID?: string | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* The sponsee account whose sponsorship is being ended. Only valid for
|
|
143
|
+
* `tfSponsorshipEnd`; omit when `Account` itself is the sponsee. Must
|
|
144
|
+
* not be present for Create / Reassign.
|
|
145
|
+
*/
|
|
146
|
+
Sponsee?: string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* The new sponsor for Create / Reassign. Must NOT be present for End.
|
|
149
|
+
* Required for Create / Reassign.
|
|
150
|
+
*/
|
|
151
|
+
Sponsor?: string | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Sponsor flags. Must include `spfSponsorReserve` (0x00000002) for
|
|
154
|
+
* Create / Reassign; must NOT be present for End. Required for
|
|
155
|
+
* Create / Reassign.
|
|
156
|
+
*/
|
|
157
|
+
SponsorFlags?: number | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Sponsor's signature. Required for account-level (no ObjectID)
|
|
160
|
+
* Create / Reassign; optional for object-level Create / Reassign.
|
|
161
|
+
*/
|
|
162
|
+
SponsorSignature?: SponsorSignatureProps | undefined;
|
|
163
|
+
Fee?: string | undefined;
|
|
164
|
+
Sequence?: number | undefined;
|
|
165
|
+
}
|
|
166
|
+
export interface SponsorshipTransfer extends Readonly<SponsorshipTransferProps> {
|
|
167
|
+
readonly TransactionType: 'SponsorshipTransfer';
|
|
168
|
+
validate(): void;
|
|
169
|
+
toJSON(): Record<string, unknown>;
|
|
170
|
+
with(overrides: Partial<SponsorshipTransferProps>): SponsorshipTransfer;
|
|
171
|
+
}
|
|
172
|
+
export declare function sponsorshipTransfer(props: SponsorshipTransferProps): SponsorshipTransfer;
|
|
173
|
+
//# sourceMappingURL=sponsorship-transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sponsorship-transfer.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/sponsorship-transfer.ts"],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C,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,mBAAoB,SAAQ,QAAQ,CAAC,wBAAwB,CAAC;IAC7E,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC;IAChD,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,wBAAwB,CAAC,GAAG,mBAAmB,CAAC;CACzE;AAmHD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,wBAAwB,GAC9B,mBAAmB,CAyJrB"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { SponsorshipTransferFlags } from '../../types/flags.js';
|
|
2
|
+
import { isAccount, isHex, isRecord, isString } from '../../validation/helpers.js';
|
|
3
|
+
import { ValidationError } from '../../errors.js';
|
|
4
|
+
import { buildFrozenTx, mergeForWith, require } from '../shape.js';
|
|
5
|
+
// ─── Spec constants ──────────────────────────────────────────────────
|
|
6
|
+
// HASH256 ledger entry ID — 32 bytes = 64 hex characters.
|
|
7
|
+
const HASH256_LENGTH = 64;
|
|
8
|
+
// Sponsor flags bitfield. Mirrors the xrpl.js `SponsorFlags` enum
|
|
9
|
+
// (`packages/xrpl/src/models/transactions/common.ts` lines 660–665).
|
|
10
|
+
// For the three documented scenarios only `spfSponsorReserve` is set;
|
|
11
|
+
// any other bit is rejected by the factory.
|
|
12
|
+
const SPF_SPONSOR_RESERVE = 0x00000002;
|
|
13
|
+
// ─── Helpers ─────────────────────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Extract the three mode-flag booleans and the numeric flag value from
|
|
16
|
+
* either the numeric or boolean-map form. Mirrors xrpl.js
|
|
17
|
+
* `validateSponsorshipTransfer` lines 96–115.
|
|
18
|
+
*/
|
|
19
|
+
function getModeFlags(rawFlags) {
|
|
20
|
+
let numericFlags = 0;
|
|
21
|
+
let isEnd = false;
|
|
22
|
+
let isCreate = false;
|
|
23
|
+
let isReassign = false;
|
|
24
|
+
if (typeof rawFlags === 'number') {
|
|
25
|
+
numericFlags = rawFlags;
|
|
26
|
+
isEnd = (numericFlags & SponsorshipTransferFlags.tfSponsorshipEnd) !== 0;
|
|
27
|
+
isCreate =
|
|
28
|
+
(numericFlags & SponsorshipTransferFlags.tfSponsorshipCreate) !== 0;
|
|
29
|
+
isReassign =
|
|
30
|
+
(numericFlags & SponsorshipTransferFlags.tfSponsorshipReassign) !== 0;
|
|
31
|
+
}
|
|
32
|
+
else if (isRecord(rawFlags)) {
|
|
33
|
+
isEnd = rawFlags['tfSponsorshipEnd'] === true;
|
|
34
|
+
isCreate = rawFlags['tfSponsorshipCreate'] === true;
|
|
35
|
+
isReassign = rawFlags['tfSponsorshipReassign'] === true;
|
|
36
|
+
numericFlags =
|
|
37
|
+
(isEnd ? SponsorshipTransferFlags.tfSponsorshipEnd : 0) |
|
|
38
|
+
(isCreate ? SponsorshipTransferFlags.tfSponsorshipCreate : 0) |
|
|
39
|
+
(isReassign ? SponsorshipTransferFlags.tfSponsorshipReassign : 0);
|
|
40
|
+
}
|
|
41
|
+
return { numericFlags, isEnd, isCreate, isReassign };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Validate the shape of a SponsorSignature object. Mirrors the xrpl.js
|
|
45
|
+
* `SponsorSignature` discriminated union
|
|
46
|
+
* (`packages/xrpl/src/models/common/index.ts` lines 57–69).
|
|
47
|
+
*/
|
|
48
|
+
function validateSponsorSignature(value, path) {
|
|
49
|
+
if (!isRecord(value)) {
|
|
50
|
+
throw new ValidationError(`${path}: SponsorSignature must be an object`);
|
|
51
|
+
}
|
|
52
|
+
const hasSingleSign = value['SigningPubKey'] !== undefined ||
|
|
53
|
+
value['TxnSignature'] !== undefined;
|
|
54
|
+
const hasMultiSign = value['Signers'] !== undefined;
|
|
55
|
+
if (hasSingleSign && hasMultiSign) {
|
|
56
|
+
throw new ValidationError(`${path}: SponsorSignature must not combine SigningPubKey/TxnSignature with Signers`);
|
|
57
|
+
}
|
|
58
|
+
if (!hasSingleSign && !hasMultiSign) {
|
|
59
|
+
throw new ValidationError(`${path}: SponsorSignature must include either single-sign fields or Signers`);
|
|
60
|
+
}
|
|
61
|
+
if (hasSingleSign) {
|
|
62
|
+
if (!isString(value['SigningPubKey']) || value['SigningPubKey'].length === 0) {
|
|
63
|
+
throw new ValidationError(`${path}: SponsorSignature.SigningPubKey must be a non-empty string`);
|
|
64
|
+
}
|
|
65
|
+
if (!isString(value['TxnSignature']) || value['TxnSignature'].length === 0) {
|
|
66
|
+
throw new ValidationError(`${path}: SponsorSignature.TxnSignature must be a non-empty string`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const signers = value['Signers'];
|
|
71
|
+
if (!Array.isArray(signers) || signers.length === 0) {
|
|
72
|
+
throw new ValidationError(`${path}: SponsorSignature.Signers must be a non-empty array`);
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < signers.length; i++) {
|
|
75
|
+
const entry = signers[i];
|
|
76
|
+
if (!isRecord(entry)) {
|
|
77
|
+
throw new ValidationError(`${path}: SponsorSignature.Signers[${i}] must be an object`);
|
|
78
|
+
}
|
|
79
|
+
const inner = entry['Signer'];
|
|
80
|
+
if (!isRecord(inner)) {
|
|
81
|
+
throw new ValidationError(`${path}: SponsorSignature.Signers[${i}].Signer must be an object`);
|
|
82
|
+
}
|
|
83
|
+
if (!isString(inner['Account']) ||
|
|
84
|
+
!isString(inner['TxnSignature']) ||
|
|
85
|
+
!isString(inner['SigningPubKey'])) {
|
|
86
|
+
throw new ValidationError(`${path}: SponsorSignature.Signers[${i}].Signer must include Account, TxnSignature, and SigningPubKey strings`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// ─── Factory ─────────────────────────────────────────────────────────
|
|
92
|
+
export function sponsorshipTransfer(props) {
|
|
93
|
+
// ── Account ── required, must be a valid XRPL classic or X-address.
|
|
94
|
+
require(props.Account, 'SponsorshipTransfer: Account is required', isAccount);
|
|
95
|
+
// ── Mode flag dispatch ── exactly one of three mode bits must be set.
|
|
96
|
+
const { isEnd, isCreate, isReassign } = getModeFlags(props.Flags);
|
|
97
|
+
const scenarioCount = (isEnd ? 1 : 0) + (isCreate ? 1 : 0) + (isReassign ? 1 : 0);
|
|
98
|
+
if (scenarioCount === 0) {
|
|
99
|
+
throw new ValidationError('SponsorshipTransfer: must specify exactly one scenario flag (tfSponsorshipEnd, tfSponsorshipCreate, or tfSponsorshipReassign)');
|
|
100
|
+
}
|
|
101
|
+
if (scenarioCount > 1) {
|
|
102
|
+
throw new ValidationError('SponsorshipTransfer: cannot specify multiple scenario flags (tfSponsorshipEnd, tfSponsorshipCreate, tfSponsorshipReassign are mutually exclusive)');
|
|
103
|
+
}
|
|
104
|
+
// ── ObjectID ── if present, 64-char hex.
|
|
105
|
+
if (props.ObjectID !== undefined) {
|
|
106
|
+
if (!isString(props.ObjectID) ||
|
|
107
|
+
!isHex(props.ObjectID) ||
|
|
108
|
+
props.ObjectID.length !== HASH256_LENGTH) {
|
|
109
|
+
throw new ValidationError('SponsorshipTransfer: ObjectID must be a 64-character hexadecimal string');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// ── End-mode rules ──
|
|
113
|
+
// - Sponsee is allowed (and optional).
|
|
114
|
+
// - Sponsor / SponsorFlags must NOT be present.
|
|
115
|
+
if (isEnd) {
|
|
116
|
+
if (props.Sponsor !== undefined) {
|
|
117
|
+
throw new ValidationError('SponsorshipTransfer: Sponsor field must not be present for tfSponsorshipEnd scenario');
|
|
118
|
+
}
|
|
119
|
+
if (props.SponsorFlags !== undefined) {
|
|
120
|
+
throw new ValidationError('SponsorshipTransfer: SponsorFlags field must not be present for tfSponsorshipEnd scenario');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// ── Create / Reassign rules ──
|
|
124
|
+
// - Sponsor REQUIRED, must be a valid account, must not equal Account.
|
|
125
|
+
// - SponsorFlags REQUIRED with spfSponsorReserve bit set.
|
|
126
|
+
// - Sponsee MUST NOT be present.
|
|
127
|
+
// - SponsorSignature REQUIRED when ObjectID is omitted (account-level).
|
|
128
|
+
if (isCreate || isReassign) {
|
|
129
|
+
if (props.Sponsee !== undefined) {
|
|
130
|
+
throw new ValidationError('SponsorshipTransfer: Sponsee field must not be present for tfSponsorshipCreate or tfSponsorshipReassign scenarios');
|
|
131
|
+
}
|
|
132
|
+
if (props.Sponsor === undefined) {
|
|
133
|
+
throw new ValidationError('SponsorshipTransfer: Sponsor field is required for tfSponsorshipCreate and tfSponsorshipReassign scenarios');
|
|
134
|
+
}
|
|
135
|
+
if (!isAccount(props.Sponsor)) {
|
|
136
|
+
throw new ValidationError('SponsorshipTransfer: Sponsor must be a valid account address');
|
|
137
|
+
}
|
|
138
|
+
if (props.Sponsor === props.Account) {
|
|
139
|
+
throw new ValidationError('SponsorshipTransfer: Account and Sponsor cannot be the same');
|
|
140
|
+
}
|
|
141
|
+
if (props.SponsorFlags === undefined) {
|
|
142
|
+
throw new ValidationError('SponsorshipTransfer: SponsorFlags is required for tfSponsorshipCreate and tfSponsorshipReassign scenarios');
|
|
143
|
+
}
|
|
144
|
+
if (typeof props.SponsorFlags !== 'number') {
|
|
145
|
+
throw new ValidationError('SponsorshipTransfer: SponsorFlags must be a number');
|
|
146
|
+
}
|
|
147
|
+
if ((props.SponsorFlags & SPF_SPONSOR_RESERVE) !== SPF_SPONSOR_RESERVE) {
|
|
148
|
+
throw new ValidationError('SponsorshipTransfer: SponsorFlags must have the spfSponsorReserve bit set for tfSponsorshipCreate and tfSponsorshipReassign scenarios');
|
|
149
|
+
}
|
|
150
|
+
// Other bits in SponsorFlags are reserved / not allowed for the
|
|
151
|
+
// three documented scenarios. Reject anything beyond the reserve
|
|
152
|
+
// bit to surface client mistakes early.
|
|
153
|
+
if ((props.SponsorFlags & ~SPF_SPONSOR_RESERVE) !== 0) {
|
|
154
|
+
throw new ValidationError('SponsorshipTransfer: SponsorFlags may only set the spfSponsorReserve bit (0x00000002)');
|
|
155
|
+
}
|
|
156
|
+
// Account-level sponsorship: no ObjectID, so the sponsor must
|
|
157
|
+
// explicitly co-sign via SponsorSignature.
|
|
158
|
+
if (props.ObjectID === undefined && props.SponsorSignature === undefined) {
|
|
159
|
+
throw new ValidationError('SponsorshipTransfer: SponsorSignature is required for account-level tfSponsorshipCreate or tfSponsorshipReassign (no ObjectID)');
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// ── Sponsee ── valid account + identity check (End mode only).
|
|
163
|
+
if (props.Sponsee !== undefined) {
|
|
164
|
+
if (!isAccount(props.Sponsee)) {
|
|
165
|
+
throw new ValidationError('SponsorshipTransfer: Sponsee must be a valid account address');
|
|
166
|
+
}
|
|
167
|
+
if (props.Sponsee === props.Account) {
|
|
168
|
+
throw new ValidationError('SponsorshipTransfer: Account and Sponsee cannot be the same');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// ── SponsorSignature ── validate shape whenever present.
|
|
172
|
+
if (props.SponsorSignature !== undefined) {
|
|
173
|
+
validateSponsorSignature(props.SponsorSignature, 'SponsorshipTransfer');
|
|
174
|
+
}
|
|
175
|
+
return buildFrozenTx('SponsorshipTransfer', props, {
|
|
176
|
+
validate() {
|
|
177
|
+
// Validated at construction.
|
|
178
|
+
},
|
|
179
|
+
toJSON() {
|
|
180
|
+
const json = {};
|
|
181
|
+
for (const k of Object.keys(this)) {
|
|
182
|
+
if (k === 'validate' || k === 'toJSON' || k === 'with')
|
|
183
|
+
continue;
|
|
184
|
+
const v = this[k];
|
|
185
|
+
if (v !== undefined)
|
|
186
|
+
json[k] = v;
|
|
187
|
+
}
|
|
188
|
+
return json;
|
|
189
|
+
},
|
|
190
|
+
with(overrides) {
|
|
191
|
+
return sponsorshipTransfer(mergeForWith(this, overrides));
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=sponsorship-transfer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sponsorship-transfer.js","sourceRoot":"","sources":["../../../src/fp/factories/sponsorship-transfer.ts"],"names":[],"mappings":"AAqGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEnE,wEAAwE;AAExE,0DAA0D;AAC1D,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,kEAAkE;AAClE,qEAAqE;AACrE,sEAAsE;AACtE,4CAA4C;AAC5C,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAiFvC,wEAAwE;AAExE;;;;GAIG;AACH,SAAS,YAAY,CAAC,QAAiB;IAMrC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,YAAY,GAAG,QAAQ,CAAC;QACxB,KAAK,GAAG,CAAC,YAAY,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QACzE,QAAQ;YACN,CAAC,YAAY,GAAG,wBAAwB,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACtE,UAAU;YACR,CAAC,YAAY,GAAG,wBAAwB,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAC1E,CAAC;SAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,KAAK,GAAG,QAAQ,CAAC,kBAAkB,CAAC,KAAK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jE,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,CAEF,SAA4C;YAE5C,OAAO,mBAAmB,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface TicketCreateProps {
|
|
2
|
+
/** The unique address of the transaction sender. */
|
|
3
|
+
Account: string;
|
|
4
|
+
/** How many Tickets to create. Must be an integer in [1, 250]. */
|
|
5
|
+
TicketCount: number;
|
|
6
|
+
/** Bit-flags for this transaction. TicketCreate has no defined flags. */
|
|
7
|
+
Flags?: number | undefined;
|
|
8
|
+
/** Fee to pay, in drops of XRP. */
|
|
9
|
+
Fee?: string | undefined;
|
|
10
|
+
/** Account sequence number (auto-filled by the client in normal use). */
|
|
11
|
+
Sequence?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface TicketCreate extends Readonly<TicketCreateProps> {
|
|
14
|
+
readonly TransactionType: 'TicketCreate';
|
|
15
|
+
validate(): void;
|
|
16
|
+
toJSON(): Record<string, unknown>;
|
|
17
|
+
with(overrides: Partial<TicketCreateProps>): TicketCreate;
|
|
18
|
+
}
|
|
19
|
+
export declare function ticketCreate(props: TicketCreateProps): TicketCreate;
|
|
20
|
+
//# sourceMappingURL=ticket-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket-create.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/ticket-create.ts"],"names":[],"mappings":"AAuFA,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AAED,MAAM,WAAW,YAAa,SAAQ,QAAQ,CAAC,iBAAiB,CAAC;IAC/D,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC;IACzC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC;CAC3D;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA+CnE"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional TicketCreate factory — frozen-object style.
|
|
3
|
+
*
|
|
4
|
+
* Sets aside one or more sequence numbers as Tickets so the account can
|
|
5
|
+
* submit later transactions without worrying about ordering or
|
|
6
|
+
* cancellation races. The class-based equivalent at
|
|
7
|
+
* `src/transactions/ticket-create.ts` requires a separate `.validate()`
|
|
8
|
+
* call after construction; this factory validates at construction so an
|
|
9
|
+
* invalid tx can never exist.
|
|
10
|
+
*
|
|
11
|
+
* import { ticketCreate } from 'xrplt/fp';
|
|
12
|
+
* const tx = ticketCreate({ Account, TicketCount: 10 });
|
|
13
|
+
* const j = tx.toJSON();
|
|
14
|
+
* const tx2 = tx.with({ TicketCount: 25 });
|
|
15
|
+
*
|
|
16
|
+
* Required amendment: `TicketBatch` (XLS-0013). The per-account cap of
|
|
17
|
+
* 250 simultaneous Tickets also comes from XLS-0013.
|
|
18
|
+
*
|
|
19
|
+
* @see https://xrpl.org/docs/references/protocol/transactions/types/ticketcreate
|
|
20
|
+
* @see https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0013-tickets
|
|
21
|
+
*
|
|
22
|
+
* ## Divergences
|
|
23
|
+
*
|
|
24
|
+
* Compared with `src/transactions/ticket-create.ts`, this factory adds
|
|
25
|
+
* preclaim guards the class API skips and emits more specific error
|
|
26
|
+
* messages than the class's single-message range check.
|
|
27
|
+
*
|
|
28
|
+
* 1. **`TicketCount` must be an integer.** The class accepts any number
|
|
29
|
+
* via `!isNumber(TicketCount) || TicketCount < 1 || TicketCount > 250`
|
|
30
|
+
* (ticket-create.ts:34), so `12.5`, `-0`, and `NaN`-adjacent values
|
|
31
|
+
* silently pass. xrpl.js explicitly enforces `Number.isInteger` and
|
|
32
|
+
* maps the failure to `temINVALID_COUNT` ("must be an integer from
|
|
33
|
+
* 1 to 250").
|
|
34
|
+
* - Source: xrpl.js
|
|
35
|
+
* `repo/packages/xrpl/src/models/transactions/ticketCreate.ts:41-49`
|
|
36
|
+
* — `!Number.isInteger(TicketCount) || TicketCount < 1 ||
|
|
37
|
+
* TicketCount > MAX_TICKETS` ⇒ "TicketCreate: TicketCount must be
|
|
38
|
+
* an integer from 1 to 250".
|
|
39
|
+
*
|
|
40
|
+
* 2. **Distinct error messages for missing-vs-wrong-type-vs-out-of-range.**
|
|
41
|
+
* The class collapses every failure into `"TicketCount must be
|
|
42
|
+
* between 1 and 250"`, which makes debugging ambiguous (is `undefined`
|
|
43
|
+
* a "missing field" or "out of range"?). xrpl.js emits three
|
|
44
|
+
* separate messages — `"missing field TicketCount"`,
|
|
45
|
+
* `"TicketCount must be a number"`, and
|
|
46
|
+
* `"TicketCount must be an integer from 1 to 250"`. The factory
|
|
47
|
+
* mirrors that ordering for parity with the canonical validator.
|
|
48
|
+
* - Source: xrpl.js `ticketCreate.ts:33-49`.
|
|
49
|
+
*
|
|
50
|
+
* 3. **`Account` must be a valid XRPL classic or X-address.** The class
|
|
51
|
+
* inherits `validateBaseTransaction`'s `isString(Account)` check
|
|
52
|
+
* (transactions/common.ts validateBaseTransaction: `validateRequiredField(common, 'Account', isString)`),
|
|
53
|
+
* which accepts any string — typos like `"r…"` slip through. The
|
|
54
|
+
* factory uses `isAccount` so an obvious typo is caught at
|
|
55
|
+
* construction.
|
|
56
|
+
* - Source: xrpl-dev-portal basic-data-types.md (`AccountID` is a
|
|
57
|
+
* classic address or X-address).
|
|
58
|
+
*
|
|
59
|
+
* 4. **`TicketCount` upper bound is per-tx, not per-account.** The
|
|
60
|
+
* factory enforces only the per-transaction maximum of 250 (XLS-0013
|
|
61
|
+
* §"TicketBatch" / `temINVALID_COUNT`). The cross-field invariant
|
|
62
|
+
* "account already owns ≥ (250 − TicketCount) Tickets ⇒ `tecDIR_FULL`"
|
|
63
|
+
* requires querying the ledger and is out of scope for a stateless
|
|
64
|
+
* constructor. The factory documents this so callers know to use
|
|
65
|
+
* `account_info` to pre-check `account_data.TicketCount` before
|
|
66
|
+
* submitting a large batch.
|
|
67
|
+
* - Source: XLS-0013 §"New Transactions: TicketBatch" line 561-563
|
|
68
|
+
* and xrpl-dev-portal `ticketcreate.md` Error Cases row
|
|
69
|
+
* `tecDIR_FULL`.
|
|
70
|
+
*/
|
|
71
|
+
import { isAccount, isNumber } from '../../validation/helpers.js';
|
|
72
|
+
import { ValidationError } from '../../errors.js';
|
|
73
|
+
import { buildFrozenTx, mergeForWith, require } from '../shape.js';
|
|
74
|
+
// ─── Spec constants ──────────────────────────────────────────────────
|
|
75
|
+
/**
|
|
76
|
+
* Maximum number of Tickets a single `TicketCreate` transaction can
|
|
77
|
+
* create. From XLS-0013 §"New Transactions: TicketBatch" line 561: "A
|
|
78
|
+
* `TicketCreate` transaction can create up to 250 `Ticket`s in a single
|
|
79
|
+
* transaction." Also exported as the canonical `MAX_TICKETS` constant
|
|
80
|
+
* in xrpl.js `ticketCreate.ts:21`.
|
|
81
|
+
*/
|
|
82
|
+
const MAX_TICKETS_PER_TX = 250;
|
|
83
|
+
// ─── Factory ─────────────────────────────────────────────────────────
|
|
84
|
+
export function ticketCreate(props) {
|
|
85
|
+
// ── Account ── required, must be a valid XRPL classic or X-address.
|
|
86
|
+
require(props.Account, 'TicketCreate: Account is required and must be a valid XRPL address', isAccount);
|
|
87
|
+
// ── TicketCount ── required. Three distinct errors (xrpl.js parity):
|
|
88
|
+
// "missing field", "must be a number", "must be an integer from 1 to 250".
|
|
89
|
+
if (props.TicketCount === undefined) {
|
|
90
|
+
throw new ValidationError('TicketCreate: missing field TicketCount');
|
|
91
|
+
}
|
|
92
|
+
if (!isNumber(props.TicketCount)) {
|
|
93
|
+
throw new ValidationError('TicketCreate: TicketCount must be a number');
|
|
94
|
+
}
|
|
95
|
+
if (!Number.isInteger(props.TicketCount) ||
|
|
96
|
+
props.TicketCount < 1 ||
|
|
97
|
+
props.TicketCount > MAX_TICKETS_PER_TX) {
|
|
98
|
+
throw new ValidationError(`TicketCreate: TicketCount must be an integer from 1 to ${MAX_TICKETS_PER_TX}`);
|
|
99
|
+
}
|
|
100
|
+
return buildFrozenTx('TicketCreate', props, {
|
|
101
|
+
validate() {
|
|
102
|
+
// Validated at construction.
|
|
103
|
+
},
|
|
104
|
+
toJSON() {
|
|
105
|
+
const json = {};
|
|
106
|
+
for (const k of Object.keys(this)) {
|
|
107
|
+
if (k === 'validate' || k === 'toJSON' || k === 'with')
|
|
108
|
+
continue;
|
|
109
|
+
const v = this[k];
|
|
110
|
+
if (v !== undefined)
|
|
111
|
+
json[k] = v;
|
|
112
|
+
}
|
|
113
|
+
return json;
|
|
114
|
+
},
|
|
115
|
+
with(overrides) {
|
|
116
|
+
return ticketCreate(mergeForWith(this, overrides));
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=ticket-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket-create.js","sourceRoot":"","sources":["../../../src/fp/factories/ticket-create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,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,CAAqB,SAAqC;YAC5D,OAAO,YAAY,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QACrD,CAAC;KACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functional TrustSet factory — frozen-object style.
|
|
3
|
+
*
|
|
4
|
+
* Creates, modifies, or deletes a trust line linking `Account` to a peer
|
|
5
|
+
* for an issued (IOU) currency. Validation happens at construction;
|
|
6
|
+
* there is no way to construct an invalid tx.
|
|
7
|
+
*
|
|
8
|
+
* import { trustSet } from 'xrplt/fp';
|
|
9
|
+
* const tx = trustSet({
|
|
10
|
+
* Account,
|
|
11
|
+
* LimitAmount: { currency: 'USD', issuer: GATEWAY, value: '100' },
|
|
12
|
+
* });
|
|
13
|
+
* const j = tx.toJSON();
|
|
14
|
+
* const tx2 = tx.with({ Flags: 0x00020000 }); // tfSetNoRipple
|
|
15
|
+
*
|
|
16
|
+
* @see https://xrpl.org/docs/references/protocol/transactions/types/trustset
|
|
17
|
+
*
|
|
18
|
+
* ## Divergences
|
|
19
|
+
* The factory enforces six preclaim guards the class API
|
|
20
|
+
* (`src/transactions/trust-set.ts`) skips. The class only checks that
|
|
21
|
+
* `LimitAmount` passes `isAmount`, which accepts all three Amount forms
|
|
22
|
+
* (XRP drops, IssuedCurrency, MPT) — none of which is the shape the spec
|
|
23
|
+
* actually mandates for a trustline.
|
|
24
|
+
*
|
|
25
|
+
* 1. `LimitAmount` must be an `IssuedCurrencyAmount` (currency +
|
|
26
|
+
* issuer + value), not a generic `Amount`.
|
|
27
|
+
* Source: xrpl-dev-portal
|
|
28
|
+
* `docs/references/protocol/transactions/types/trustset.md` line 38:
|
|
29
|
+
* "`LimitAmount`.`currency` ... 'XRP' is invalid". XRP amounts are
|
|
30
|
+
* rejected as well as MPT amounts (`docs/concepts/tokens/fungible-tokens/trust-line-tokens.md`:
|
|
31
|
+
* "Trust lines tokens ... are tracked in trust lines ... in contrast
|
|
32
|
+
* to [Multi-Purpose Tokens]"). xrpl.js `validateTrustSet` calls
|
|
33
|
+
* `isAmount(LimitAmount)` which accepts XRP drops strings and
|
|
34
|
+
* `MPTAmount` objects; the class inherits that gap.
|
|
35
|
+
*
|
|
36
|
+
* 2. `LimitAmount.currency` must not be the literal `"XRP"`.
|
|
37
|
+
* Source: xrpl-dev-portal
|
|
38
|
+
* `docs/references/protocol/transactions/types/trustset.md` line 38:
|
|
39
|
+
* "`LimitAmount`.`currency` ... 'XRP' is invalid". The class does
|
|
40
|
+
* not distinguish the rejected `"XRP"` case from any other valid
|
|
41
|
+
* currency code.
|
|
42
|
+
*
|
|
43
|
+
* 3. `LimitAmount.issuer` must be a valid XRPL classic or X-address.
|
|
44
|
+
* Source: xrpl-dev-portal
|
|
45
|
+
* `docs/references/protocol/transactions/types/trustset.md` line 40:
|
|
46
|
+
* "`LimitAmount`.`issuer` | String | (Amount.issuer) | The address
|
|
47
|
+
* of the account to extend trust to". The class validates the
|
|
48
|
+
* issuer as a free-form string; xrpl.js's `isIssuedCurrencyAmount`
|
|
49
|
+
* checks only that the field is a string.
|
|
50
|
+
*
|
|
51
|
+
* 4. `LimitAmount.value` must be a non-negative XRPL string-number
|
|
52
|
+
* (decimal or scientific).
|
|
53
|
+
* Source: xrpl-dev-portal
|
|
54
|
+
* `docs/references/protocol/data-types/currency-formats.md` line 63
|
|
55
|
+
* (`value` column of the issued-currency amount table) — "Quoted
|
|
56
|
+
* decimal representation of the amount of the token. This can
|
|
57
|
+
* include scientific notation". Line 28 — "Minimum value: `0`.
|
|
58
|
+
* (Cannot be negative.)" The class accepts any string and does
|
|
59
|
+
* not parse or sign-check the value.
|
|
60
|
+
*
|
|
61
|
+
* 5. `Account` must be a valid XRPL classic or X-address.
|
|
62
|
+
* Source: xrpl-dev-portal
|
|
63
|
+
* `docs/references/protocol/transactions/types/trustset.md` line 18
|
|
64
|
+
* — example `"Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX"`.
|
|
65
|
+
* The class only checks `typeof === 'string'` via the base
|
|
66
|
+
* validator; the factory uses `isAccount`.
|
|
67
|
+
*
|
|
68
|
+
* 6. `QualityIn` and `QualityOut` must be non-negative integers in the
|
|
69
|
+
* UInt32 range [0, 0xFFFFFFFF].
|
|
70
|
+
* Source: xrpl-dev-portal
|
|
71
|
+
* `docs/references/protocol/transactions/types/trustset.md`
|
|
72
|
+
* lines 41–42 — `QualityIn | Number | UInt32` and `QualityOut |
|
|
73
|
+
* Number | UInt32`. xrpl.js `validateTrustSet` checks only
|
|
74
|
+
* `typeof === 'number'`; the class inherits that gap and accepts
|
|
75
|
+
* negatives, non-integers, and out-of-range values.
|
|
76
|
+
*/
|
|
77
|
+
import type { IssuedCurrencyAmount } from '../../types/amounts.js';
|
|
78
|
+
import type { TrustSetFlagsInterface } from '../../types/flags.js';
|
|
79
|
+
export interface TrustSetProps {
|
|
80
|
+
/** The unique address of the transaction sender (the trustor). */
|
|
81
|
+
Account: string;
|
|
82
|
+
/** The limit and currency for the trust line. */
|
|
83
|
+
LimitAmount: IssuedCurrencyAmount;
|
|
84
|
+
/** Quality of incoming liquidity (UInt32; 0 = 100%). */
|
|
85
|
+
QualityIn?: number | undefined;
|
|
86
|
+
/** Quality of outgoing liquidity (UInt32; 0 = 100%). */
|
|
87
|
+
QualityOut?: number | undefined;
|
|
88
|
+
/** Bit-flags for this transaction. */
|
|
89
|
+
Flags?: number | TrustSetFlagsInterface | undefined;
|
|
90
|
+
Fee?: string | undefined;
|
|
91
|
+
Sequence?: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
export interface TrustSet extends Readonly<TrustSetProps> {
|
|
94
|
+
readonly TransactionType: 'TrustSet';
|
|
95
|
+
validate(): void;
|
|
96
|
+
toJSON(): Record<string, unknown>;
|
|
97
|
+
with(overrides: Partial<TrustSetProps>): TrustSet;
|
|
98
|
+
}
|
|
99
|
+
export declare function trustSet(props: TrustSetProps): TrustSet;
|
|
100
|
+
//# sourceMappingURL=trust-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trust-set.d.ts","sourceRoot":"","sources":["../../../src/fp/factories/trust-set.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAiBnE,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,WAAW,EAAE,oBAAoB,CAAC;IAClC,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,sCAAsC;IACtC,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,QAAS,SAAQ,QAAQ,CAAC,aAAa,CAAC;IACvD,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC;IACrC,QAAQ,IAAI,IAAI,CAAC;IACjB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,QAAQ,CAAC;CACnD;AAqED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CA4DvD"}
|