Skip to content

Commit

Permalink
add nft create offer
Browse files Browse the repository at this point in the history
  • Loading branch information
pdp2121 committed Feb 4, 2025
1 parent 80081db commit 468ddb3
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shared/requests/submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ components:
NFTokenAcceptOffer: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
NFTokenBurn: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
NFTokenCancelOffer: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
NFTokenCreateOffer: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand Down Expand Up @@ -131,6 +132,7 @@ components:
- $ref: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
- $ref: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
- $ref: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
- $ref: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here

description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
Expand Down Expand Up @@ -178,6 +180,7 @@ components:
NFTokenAcceptOffer: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
NFTokenBurn: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
NFTokenCancelOffer: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
NFTokenCreateOffer: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
- $ref: '../transactions/oracle_set.yaml#/components/schemas/OracleSetTransaction'
Expand Down Expand Up @@ -210,6 +213,7 @@ components:
- $ref: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
- $ref: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
- $ref: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
- $ref: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here
description: 'Transaction definition in JSON format, optionally omitting any auto-fillable fields.'
required:
Expand Down Expand Up @@ -316,6 +320,7 @@ components:
NFTokenAcceptOffer: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
NFTokenBurn: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
NFTokenCancelOffer: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
NFTokenCreateOffer: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV1'
Expand Down Expand Up @@ -349,6 +354,7 @@ components:
- $ref: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
- $ref: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
- $ref: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
- $ref: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here

SubmitSuccessResponseV2:
Expand Down Expand Up @@ -391,6 +397,7 @@ components:
NFTokenAcceptOffer: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
NFTokenBurn: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
NFTokenCancelOffer: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
NFTokenCreateOffer: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here
oneOf:
- $ref: '../transactions/payment.yaml#/components/schemas/PaymentTransactionV2'
Expand Down Expand Up @@ -424,6 +431,7 @@ components:
- $ref: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferTransaction'
- $ref: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnTransaction'
- $ref: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferTransaction'
- $ref: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferTransaction'
# TODO: Add other transaction types here

SubmitErrorResponse:
Expand Down Expand Up @@ -452,6 +460,7 @@ components:
- $ref: '../transactions/nftoken_accept_offer.yaml#/components/schemas/NFTokenAcceptOfferErrorCode'
- $ref: '../transactions/nftoken_burn.yaml#/components/schemas/NFTokenBurnErrorCode'
- $ref: '../transactions/nftoken_cancel_offer.yaml#/components/schemas/NFTokenCancelOfferErrorCode'
- $ref: '../transactions/nftoken_create_offer.yaml#/components/schemas/NFTokenCreateOfferErrorCode'
- enum:
- amendmentBlocked
- highFee
Expand Down
110 changes: 110 additions & 0 deletions shared/transactions/nftoken_create_offer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
components:
schemas:
NFTokenCreateOfferTransaction:
$id: NFTokenCreateOfferTransaction
allOf:
- $ref: '../base.yaml#/components/schemas/BaseTransaction'
type: object
description: |
Creates either a new Sell offer for an NFToken owned by the account executing the transaction, or a new
Buy offer for an NFToken owned by another account.
If successful, the transaction creates an NFTokenOffer object. Each offer counts as one object towards
the owner reserve of the account that placed the offer.
required:
- NFTokenID
- Amount
properties:
Owner:
type: string
description: |
(Optional) Who owns the corresponding NFToken. If the offer is to buy a token, this field must be
present and it must be different than the Account field (since an offer to buy a token one already
holds is meaningless). If the offer is to sell a token, this field must not be present, as the owner
is, implicitly, the same as the Account (since an offer to sell a token one doesn't already hold is meaningless).
NFTokenID:
type: string
description: |
Identifies the NFToken object that the offer references.
Amount:
type: object
description: |
Indicates the amount expected or offered for the corresponding NFToken. The amount must be non-zero,
except where this is an offer to sell and the asset is XRP; then, it is legal to specify an amount of zero,
which means that the current owner of the token is giving it away, gratis, either to anyone at all, or to
the account identified by the Destination field.
Expiration:
type: integer
format: uint32
description: |
(Optional) Time after which the offer is no longer active, in seconds since the Ripple Epoch.
Destination:
type: string
description: |
(Optional) If present, indicates that this offer may only be accepted by the specified account.
Attempts by other accounts to accept this offer MUST fail.
x-custom-validation:
conditionalRequired:
- field: Owner
requiresFlag: tfSellNFToken
condition: false
message: 'Must be present for buy offers.'
conditionalForbidden:
- field: Owner
requiresFlag: tfSellNFToken
condition: true
message: 'Must not be present for sell offers.'
greaterThan:
- field: Amount
requiresFlag: tfSellNFToken
condition: false
value: 0
message: 'Must be greater than 0 for a buy offer.'
notEqual:
- field: Destination
toField: Account
message: 'Must not be equal to the account.'
- field: Owner
toField: Account
message: 'Must not be equal to the account.'
NFTokenCreateOfferFlag:
$id: NFTokenCreateOfferFlag
type: string
enum:
- tfSellNFToken: 0x00000001
x-enum-descriptions:
tfSellNFToken: If enabled, indicates that the offer is a sell offer. Otherwise, it is a buy offer.
NFTokenCreateOfferErrorCode:
$id: NFTokenCreateOfferErrorCode
type: string
enum:
- temDISABLED
- temBAD_AMOUNT
- temBAD_EXPIRATION
- tecDIR_FULL
- tecEXPIRED
- tecFROZEN
- tecINSUFFICIENT_RESERVE
- tecNO_DST
- tecNO_ENTRY
- tecNO_ISSUER
- tecNO_LINE
- tecNO_PERMISSION
- tecUNFUNDED_OFFER
- tefNFTOKEN_IS_NOT_TRANSFERABLE
description: Enum representing possible error codes for NFTokenCreateOffer transactions.
x-enum-descriptions:
temDISABLED: The NonFungibleTokensV1 amendment is not enabled.
temBAD_AMOUNT: The Amount field is not valid. For example, the amount was zero for a buy offer, or the amount is denominated in fungible tokens but the NFToken has the lsfOnlyXRP flag enabled.
temBAD_EXPIRATION: The specified Expiration time is invalid (for example, 0).
tecDIR_FULL: The sender already owns too many objects in the ledger, or there are already too many offers to buy or sell this token.
tecEXPIRED: The specified Expiration time has already passed.
tecFROZEN: The Amount is denominated in fungible tokens, but one of the trust lines that would receive tokens from this offer is frozen. This could be the seller's trust line or the NFToken's issuer's trust line (if the NFToken has a transfer fee).
tecINSUFFICIENT_RESERVE: The sender does not have enough XRP to meet the reserve requirement after placing this offer.
tecNO_DST: The account specified in the Destination field does not exist in the ledger.
tecNO_ENTRY: The NFToken is not owned by the expected account.
tecNO_ISSUER: The issuer specified in the Amount field does not exist.
tecNO_LINE: The Amount field is denominated in fungible tokens, but the NFToken's issuer does not have a trust line for those tokens and the NFToken does not have the lsfTrustLine flag enabled.
tecNO_PERMISSION: The Destination account blocks incoming NFTokenOffers. (Requires the DisallowIncoming amendment.)
tecUNFUNDED_OFFER: For a buy offer, the sender does have the funds specified in the Amount field available. If the Amount is XRP, this could be due to the reserve requirement; if the Amount is denominated in fungible tokens, this could be because they are frozen.
tefNFTOKEN_IS_NOT_TRANSFERABLE: The NFToken has the lsfTransferable flag disabled and this transaction would not transfer the NFToken to or from the issuer.

0 comments on commit 468ddb3

Please sign in to comment.