-
Notifications
You must be signed in to change notification settings - Fork 88
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
feat(backend): tenant support for wallet address (#3114) #3152
base: 2893/multi-tenancy-v1
Are you sure you want to change the base?
Changes from all commits
2f74c4e
61d45f7
d57bcc6
57a663d
fb3d702
e5cc2b5
c824c56
9211ca3
e2bbc79
fda0653
151c3aa
d6257fe
86d9a39
3625938
6f16eaa
490f748
10bc6ab
d5cc314
fc01ef7
87213de
0a37b3c
3805b10
92fc1ac
0ad7ccc
645e181
cdc2bda
c44cd03
4e17260
a9f0fff
7d562b5
b5a1667
f29862a
868221c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return Promise.all([ | ||
knex.schema.alterTable('walletAddresses', function (table) { | ||
table.uuid('tenantId').index().notNullable() | ||
//table.foreign(['tenantId']).references('tenants.id') | ||
}) | ||
]) | ||
} | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return Promise.all([ | ||
knex.schema.alterTable('walletAddresses', function (table) { | ||
table.dropIndex('tenantId') | ||
table.dropColumn('tenantId') | ||
}) | ||
]) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { WebhookEvent } from '../../webhook/model' | |
import { WalletAddressKey } from '../../open_payments/wallet_address/key/model' | ||
import { AmountJSON } from '../amount' | ||
import { WalletAddressAdditionalProperty } from './additional_property/model' | ||
import { Tenant } from '../../tenants/model' | ||
|
||
export class WalletAddress | ||
extends BaseModel | ||
|
@@ -18,6 +19,14 @@ export class WalletAddress | |
} | ||
|
||
static relationMappings = () => ({ | ||
tenant: { | ||
relation: Model.HasOneRelation, | ||
modelClass: Tenant, | ||
join: { | ||
from: 'walletAddresses.tenantId', | ||
to: 'tenants.id' | ||
} | ||
}, | ||
asset: { | ||
relation: Model.HasOneRelation, | ||
modelClass: Asset, | ||
|
@@ -53,6 +62,9 @@ export class WalletAddress | |
public readonly assetId!: string | ||
public asset!: Asset | ||
|
||
public readonly tenantId!: string | ||
public tenant!: Tenant | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally I thought we would need it, but since we have |
||
|
||
// The cumulative received amount tracked by | ||
// `wallet_address.web_monetization` webhook events. | ||
// The value should be equivalent to the following query: | ||
|
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.
This would need to be removed at a later stage (once we obtain the tenant from the signature):
#2928