This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add validation #4
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
f82861c
add `tbdex` submodule
ethanwlee 85afe97
add `json_schema` and `path` deps
ethanwlee c8edaee
remove unused pattern
ethanwlee 312412f
generate id using `TypeId`
ethanwlee 6ef095b
use `JsonSchema`
ethanwlee 42844a7
add `Validator`
ethanwlee 92f7da2
progress on `verifyOfferingRequirements()`
ethanwlee f065ff6
fix validation errors
ethanwlee 664e8f4
remove print
ethanwlee 873fb01
fix serialization issue with `requiredPaymentDetails` json schema
ethanwlee f9e127c
add `decimal` dep
ethanwlee 3dfd5e1
add `orElse` to `firstWhere()`
ethanwlee a1fcb1f
add more exception handling to `verifyOfferingRequirements()`
ethanwlee 9d68f55
change description in `having()`
ethanwlee ff5a484
add todo about explicit parsing
ethanwlee 122e982
update `getOffering()` and `getRfq()` to test `verifyOfferingRequirem…
ethanwlee fd941ec
add tests for `verifyOfferingRequirements()`
ethanwlee bd9d457
refactor `initialize()`
ethanwlee 28eb374
use `json` as variable name for `jsonEncode()`
ethanwlee 7f6a3cd
update `tbdex` submodule
ethanwlee cf0ae2a
use private instance to initialize validator
ethanwlee 9fe92cf
add just command to copy json-schemas from tbdex submodule
ethanwlee 6f82097
remove initialize validator
ethanwlee d085647
check in json schemas from tbdex submodule
ethanwlee bfe940a
update path to new json-schemas folder
ethanwlee dc37978
add get, test, and analyze
ethanwlee 80f3706
delete issue template
ethanwlee 123b34c
add ci workflow
ethanwlee 342ef5b
update exception message
ethanwlee e518f51
use `@` for all commands
ethanwlee fa613e0
update ci steps
ethanwlee 2754bdc
add dart to hermit
ethanwlee 9054022
fix property access on `dynamic`
ethanwlee de61000
add publish to none
ethanwlee b6a837d
move private constructor
ethanwlee 08ba5d2
fix metadata casts
ethanwlee c041300
remove unused constructor
ethanwlee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
|
||
- name: Init Hermit | ||
uses: cashapp/activate-hermit@v1 | ||
with: | ||
cache: true | ||
|
||
- name: Install Dependencies | ||
run: just get | ||
|
||
- name: Run Static Analysis | ||
run: just analyze | ||
|
||
- name: Run Tests | ||
run: just test | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "tbdex"] | ||
path = tbdex | ||
url = [email protected]:TBD54566975/tbdex.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
schemas: | ||
@git submodule update --init --recursive | ||
@cp -r tbdex/hosted/json-schemas lib/src/protocol | ||
|
||
get: | ||
@dart pub get | ||
|
||
test: | ||
@dart test | ||
|
||
analyze: | ||
@dart analyze |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hermit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hermit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.dart-3.3.3.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.dart-3.3.3.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.dart-3.3.3.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.just-1.25.2.pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/balance.schema.json", | ||
"type": "object", | ||
"properties": { | ||
"additionalProperties": false, | ||
"currencyCode": { | ||
"type": "string", | ||
"description": "ISO 3166 currency code string" | ||
}, | ||
"available": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "The amount available to be transacted with" | ||
} | ||
}, | ||
"required": [ | ||
"currencyCode", | ||
"available" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/close.schema.json", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"reason": { | ||
"type": "string" | ||
}, | ||
"success": { | ||
"type": "boolean" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/definitions.json", | ||
"type": "object", | ||
"definitions": { | ||
"did": { | ||
"type": "string", | ||
"pattern": "^did:([a-z0-9]+):((?:(?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))*:)*((?:[a-zA-Z0-9._-]|(?:%[0-9a-fA-F]{2}))+))((;[a-zA-Z0-9_.:%-]+=[a-zA-Z0-9_.:%-]*)*)(\/[^#?]*)?([?][^#]*)?(#.*)?$" | ||
}, | ||
"decimalString": { | ||
"type": "string", | ||
"pattern": "^([0-9]+(?:[.][0-9]+)?)$" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/message.schema.json", | ||
"definitions": { | ||
"MessageMetadata": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"from": { | ||
"$ref": "definitions.json#/definitions/did", | ||
"description": "The sender's DID" | ||
}, | ||
"to": { | ||
"$ref": "definitions.json#/definitions/did", | ||
"description": "The recipient's DID" | ||
}, | ||
"kind": { | ||
"type": "string", | ||
"enum": ["rfq", "quote", "order", "orderstatus", "close"], | ||
"description": "The message kind (e.g. rfq, quote)" | ||
}, | ||
"id": { | ||
"type": "string", | ||
"description": "The message ID" | ||
}, | ||
"exchangeId": { | ||
"type": "string", | ||
"description": "ID for a 'thread' of messages between Alice <-> PFI. Set by the first message in a thread" | ||
}, | ||
"externalId": { | ||
"type": "string", | ||
"description": "Arbitrary ID for the caller to associate with the message." | ||
}, | ||
"createdAt": { | ||
"type": "string", | ||
"description": "ISO8601 formatted string representing the timestamp" | ||
}, | ||
"protocol": { | ||
"type": "string", | ||
"description": "Version of the protocol in use (x.x format)" | ||
} | ||
}, | ||
"required": ["from", "to", "kind", "id", "exchangeId", "createdAt", "protocol"] | ||
}, | ||
"Private": { | ||
"type": "object", | ||
"description": "An ephemeral JSON object used to transmit sensitive data (e.g. PII)" | ||
} | ||
}, | ||
"type": "object", | ||
"properties": { | ||
"metadata": { | ||
"$ref": "#/definitions/MessageMetadata" | ||
}, | ||
"data": { | ||
"type": "object", | ||
"description": "The actual message content" | ||
}, | ||
"signature": { | ||
"type": "string", | ||
"description": "Signature that verifies the authenticity and integrity of a message" | ||
}, | ||
"private": { | ||
"$ref": "#/definitions/Private" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"required": ["metadata", "data", "signature"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/offering.schema.json", | ||
"type": "object", | ||
"properties": { | ||
"additionalProperties": false, | ||
"description": { | ||
"type": "string", | ||
"description": "Brief description of what is being offered." | ||
}, | ||
"payin": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"currencyCode": { | ||
"type": "string", | ||
"description": "ISO 3166 currency code string" | ||
}, | ||
"min": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Minimum amount of currency that can be requested" | ||
}, | ||
"max": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Maximum amount of currency that can be requested" | ||
}, | ||
"methods": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"kind": { | ||
"type": "string", | ||
"description": "The type of payment method. e.g. BITCOIN_ADDRESS, DEBIT_CARD, etc." | ||
}, | ||
"name": { | ||
"type": "string", | ||
"description": "Payment Method name. Expected to be rendered on screen." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "Blurb containing helpful information about the payment method. Expected to be rendered on screen. e.g. \"segwit addresses only\"" | ||
}, | ||
"group": { | ||
"type": "string", | ||
"description": "Value that can be used to group specific payment methods together (e.g. Mobile Money vs. Direct Bank Deposit)." | ||
}, | ||
"requiredPaymentDetails": { | ||
"$ref": "http://json-schema.org/draft-07/schema", | ||
"description": "A JSON Schema containing the fields that need to be collected in order to use this payment method" | ||
}, | ||
"min": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Minimum amount required to use this payment method." | ||
}, | ||
"max": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Maximum amount allowed when using this payment method." | ||
}, | ||
"fee": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Fee charged to use this payment method. Absence of this field implies that there is no _additional_ fee associated to the respective payment method." | ||
} | ||
}, | ||
"required": ["kind"] | ||
} | ||
} | ||
}, | ||
"required": ["currencyCode", "methods"] | ||
}, | ||
"payout": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"currencyCode": { | ||
"type": "string", | ||
"description": "ISO 3166 currency code string" | ||
}, | ||
"min": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Minimum amount of currency that can be requested" | ||
}, | ||
"max": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Maximum amount of currency that can be requested" | ||
}, | ||
"methods": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"kind": { | ||
"type": "string", | ||
"description": "The type of payment method. e.g. BITCOIN_ADDRESS, DEBIT_CARD, etc." | ||
}, | ||
"name": { | ||
"type": "string", | ||
"description": "Payment Method name. Expected to be rendered on screen." | ||
}, | ||
"description": { | ||
"type": "string", | ||
"description": "Blurb containing helpful information about the payment method. Expected to be rendered on screen. e.g. \"segwit addresses only\"" | ||
}, | ||
"group": { | ||
"type": "string", | ||
"description": "Value that can be used to group specific payment methods together (e.g. Mobile Money vs. Direct Bank Deposit)." | ||
}, | ||
"requiredPaymentDetails": { | ||
"$ref": "http://json-schema.org/draft-07/schema", | ||
"description": "A JSON Schema containing the fields that need to be collected in order to use this payment method" | ||
}, | ||
"min": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Minimum amount required to use this payment method." | ||
}, | ||
"max": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Maximum amount allowed when using this payment method." | ||
}, | ||
"fee": { | ||
"$ref": "definitions.json#/definitions/decimalString", | ||
"description": "Fee charged to use this payment method. absence of this field implies that there is no _additional_ fee associated to the respective payment method" | ||
}, | ||
"estimatedSettlementTime": { | ||
"type": "number", | ||
"description": "Estimated time in seconds for the payout to be settled. e.g. 3600 for 1 hour. 0 for instant settlement.", | ||
"minimum": 0 | ||
} | ||
}, | ||
"required": ["kind", "estimatedSettlementTime"] | ||
} | ||
} | ||
}, | ||
"required": ["currencyCode", "methods"] | ||
}, | ||
"payoutUnitsPerPayinUnit": { | ||
"type": "string", | ||
"description": "Number of payout currency units for one payin currency unit (i.e 290000 USD for 1 BTC)" | ||
}, | ||
"requiredClaims": { | ||
"type": "object", | ||
"description": "PresentationDefinition that describes the credential(s) the PFI requires in order to provide a quote." | ||
} | ||
}, | ||
"required": [ | ||
"description", | ||
"payin", | ||
"payout", | ||
"payoutUnitsPerPayinUnit" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/order.schema.json", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!