Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: inet:service:tenant / inet:service:subscription and lots of interface inheritance #3995

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions synapse/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1368,3 +1368,12 @@ def _timeout(delay):
"""
loop = asyncio.get_running_loop()
return _Timeout(loop.time() + delay if delay is not None else None)

def format(text, **kwargs):
'''
Similar to python str.format() but treats tokens as opaque.
'''
for name, valu in kwargs.items():
tokn = '{' + name + '}'
text = text.replace(tokn, valu)
return text
2 changes: 1 addition & 1 deletion synapse/datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ def convert(item):
if item == '$self':
return form.name

return item.format(**template)
return s_common.format(item, **template)

if isinstance(item, dict):
return {convert(k): convert(v) for (k, v) in item.items()}
Expand Down
7 changes: 5 additions & 2 deletions synapse/models/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def getModelDefs(self):
'ex': 'btc',
}),
('crypto:currency:address', ('comp', {'fields': (('coin', 'crypto:currency:coin'), ('iden', 'str')), 'sepr': '/'}), {

'interfaces': ('econ:pay:instrument',),
'template': {
'instrument': 'crypto currency address'},

'doc': 'An individual crypto currency address.',
'ex': 'btc/1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2',
}),
Expand Down Expand Up @@ -364,8 +369,6 @@ def getModelDefs(self):
'doc': 'The coin specific address identifier.', 'ro': True, }),
('desc', ('str', {}), {
'doc': 'A free-form description of the address.'}),
('contact', ('ps:contact', {}), {
invisig0th marked this conversation as resolved.
Show resolved Hide resolved
'doc': 'Contact information associated with the address.'}),
)),

('crypto:algorithm', {}, ()),
Expand Down
53 changes: 45 additions & 8 deletions synapse/models/economic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def getModelDefs(self):
'doc': 'An Issuer Id Number (IIN).'}),

('econ:pay:card', ('guid', {}), {

'interfaces': ('econ:pay:instrument',),
'template': {
'instrument': 'payment card'},

'doc': 'A single payment card.'}),

('econ:purchase', ('guid', {}), {
Expand Down Expand Up @@ -71,6 +76,11 @@ def getModelDefs(self):
'doc': 'A bank account type taxonomy.'}),

('econ:bank:account', ('guid', {}), {

'interfaces': ('econ:pay:instrument',),
'template': {
'instrument': 'bank account'},

'doc': 'A bank account.'}),

('econ:bank:balance', ('guid', {}), {
Expand All @@ -87,6 +97,25 @@ def getModelDefs(self):

('econ:bank:swift:bic', ('str', {'regex': '[A-Z]{6}[A-Z0-9]{5}'}), {
'doc': 'A Society for Worldwide Interbank Financial Telecommunication (SWIFT) Business Identifier Code (BIC).'}),

('econ:pay:instrument', ('ndef', {'interface': 'econ:pay:instrument'}), {
'doc': 'A node which may act as a payment instrument.'}),
),

'interfaces': (
('econ:pay:instrument', {

'doc': 'An interface for forms which may act as a payment instrument.',
'template': {
'instrument': 'instrument',
},

'props': (

('contact', ('ps:contact', {}), {
'doc': 'The primary contact for the {instrument}.'}),
),
}),
),

'edges': (
Expand Down Expand Up @@ -209,17 +238,26 @@ def getModelDefs(self):
('from:cash', ('bool', {}), {
'doc': 'Set to true if the payment input was in cash.'}),

('to:instrument', ('econ:pay:instrument', {}), {
invisig0th marked this conversation as resolved.
Show resolved Hide resolved
'doc': 'The payment instrument which received funds from the payment.'}),

('from:instrument', ('econ:pay:instrument', {}), {
'doc': 'The payment instrument used to make the payment.'}),

('from:account', ('econ:bank:account', {}), {
'doc': 'The bank account which made the payment.'}),
'deprecated': True,
'doc': 'Deprecated. Please use :from:instrument.'}),

('from:pay:card', ('econ:pay:card', {}), {
'doc': 'The payment card making the payment.'}),
'deprecated': True,
'doc': 'Deprecated. Please use :from:instrument.'}),

('from:contract', ('ou:contract', {}), {
'doc': 'A contract used as an aggregate payment source.'}),

('from:coinaddr', ('crypto:currency:address', {}), {
'doc': 'The crypto currency address making the payment.'}),
'deprecated': True,
'doc': 'Deprecated. Please use :from:instrument.'}),

('from:contact', ('ps:contact', {}), {
'doc': 'Contact information for the entity making the payment.'}),
Expand All @@ -228,10 +266,12 @@ def getModelDefs(self):
'doc': 'Set to true if the payment output was in cash.'}),

('to:account', ('econ:bank:account', {}), {
'doc': 'The bank account which received the payment.'}),
'deprecated': True,
'doc': 'Deprecated. Please use :to:instrument.'}),

('to:coinaddr', ('crypto:currency:address', {}), {
'doc': 'The crypto currency address receiving the payment.'}),
'deprecated': True,
'doc': 'Deprecated. Please use :to:instrument.'}),

('to:contact', ('ps:contact', {}), {
'doc': 'Contact information for the person/org being paid.'}),
Expand Down Expand Up @@ -448,9 +488,6 @@ def getModelDefs(self):
('iban', ('econ:bank:iban', {}), {
'doc': 'The IBAN for the account.'}),

('contact', ('ps:contact', {}), {
invisig0th marked this conversation as resolved.
Show resolved Hide resolved
'doc': 'The contact information associated with the bank account.'}),

('issuer', ('ou:org', {}), {
'doc': 'The bank which issued the account.'}),

Expand Down
Loading
Loading