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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
221 additions
and
69 deletions.
There are no files selected for viewing
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
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
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
35 changes: 35 additions & 0 deletions
35
lib/src/protocol/json_schemas/orderinstructions_schema.dart
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,35 @@ | ||
class OrderinstructionsSchema { | ||
static const String json = r''' | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://tbdex.dev/orderinstructions.schema.json", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"payin": { | ||
"$ref": "#/definitions/PaymentInstruction" | ||
}, | ||
"payout": { | ||
"$ref": "#/definitions/PaymentInstruction" | ||
} | ||
}, | ||
"definitions": { | ||
"PaymentInstruction": { | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"link": { | ||
"type": "string", | ||
"description": "Link to allow Alice to pay PFI, or be paid by the PFI" | ||
}, | ||
"instruction": { | ||
"type": "string", | ||
"description": "Instruction on how Alice can pay PFI, or how Alice can be paid by the PFI" | ||
} | ||
} | ||
} | ||
}, | ||
"required": ["payin", "payout"] | ||
} | ||
'''; | ||
} |
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
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
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
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
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,70 @@ | ||
import 'package:tbdex/src/protocol/models/message.dart'; | ||
import 'package:tbdex/src/protocol/models/message_data.dart'; | ||
import 'package:tbdex/src/protocol/parser.dart'; | ||
|
||
class OrderInstructions extends Message { | ||
@override | ||
final MessageMetadata metadata; | ||
@override | ||
final OrderInstructionsData data; | ||
|
||
@override | ||
Set<MessageKind> get validNext => | ||
{MessageKind.orderstatus, MessageKind.close, MessageKind.cancel}; | ||
|
||
OrderInstructions._({ | ||
required this.metadata, | ||
required this.data, | ||
String? signature, | ||
}) : super() { | ||
this.signature = signature; | ||
} | ||
|
||
static OrderInstructions create( | ||
String to, | ||
String from, | ||
String exchangeId, | ||
OrderInstructionsData data, { | ||
String? externalId, | ||
String protocol = '1.0', | ||
}) { | ||
final now = DateTime.now().toUtc().toIso8601String(); | ||
final metadata = MessageMetadata( | ||
kind: MessageKind.orderinstructions, | ||
to: to, | ||
from: from, | ||
id: Message.generateId(MessageKind.orderinstructions), | ||
exchangeId: exchangeId, | ||
createdAt: now, | ||
protocol: protocol, | ||
externalId: externalId, | ||
); | ||
|
||
return OrderInstructions._( | ||
metadata: metadata, | ||
data: data, | ||
); | ||
} | ||
|
||
static Future<OrderInstructions> parse(String rawMessage) async { | ||
final orderStatus = Parser.parseMessage(rawMessage) as OrderInstructions; | ||
await orderStatus.verify(); | ||
return orderStatus; | ||
} | ||
|
||
factory OrderInstructions.fromJson(Map<String, dynamic> json) { | ||
return OrderInstructions._( | ||
metadata: MessageMetadata.fromJson(json['metadata']), | ||
data: OrderInstructionsData.fromJson(json['data']), | ||
signature: json['signature'], | ||
); | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
return { | ||
'metadata': metadata.toJson(), | ||
'data': data.toJson(), | ||
'signature': 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
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
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
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
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
Submodule tbdex
updated
6 files
Oops, something went wrong.