@nina-protocol/nina-db 0.0.76 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.alterTable('subscriptions', table => {
7
+ table.string('publicKey').notNullable().alter();
8
+ });
9
+ };
10
+ /**
11
+ * @param { import("knex").Knex } knex
12
+ * @returns { Promise<void> }
13
+ */
14
+ export const down = function (knex) {
15
+ return knex.schema.alterTable('subscriptions', table => {
16
+ table.string('publicKey').nullable().alter();
17
+ });
18
+ };
@@ -58,7 +58,7 @@ export default class Release extends Model {
58
58
  let metadataAccount = (await metaplex.nfts().findAllByMintList({ mints: [releaseAccount.releaseMint] }, { commitment: 'confirmed' }))[0];
59
59
  let json;
60
60
  try {
61
- json = (await axios.get(metadataAccount.uri).replace('www.', '').replace('arweave.net', 'gateway.irys.xyz')).data;
61
+ json = (await axios.get(metadataAccount.uri.replace('www.', '').replace('arweave.net', 'gateway.irys.xyz'))).data;
62
62
  }
63
63
  catch (error) {
64
64
  json = (await axios.get(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net'))).data;
@@ -11,7 +11,7 @@ class Subscription extends Model {
11
11
  static get jsonSchema() {
12
12
  return {
13
13
  type: 'object',
14
- required: ['publicKey', 'datetime'],
14
+ required: ['datetime'],
15
15
  properties: {
16
16
  publicKey: { type: 'string' },
17
17
  datetime: { type: 'string' },
@@ -24,15 +24,15 @@ class Subscription extends Model {
24
24
  },
25
25
  };
26
26
  }
27
- static async findOrCreate({ publicKey, from, to, datetime, subscriptionType }) {
28
- let subscription = await Subscription.query().findOne({ publicKey });
27
+ static async findOrCreate({ from, to, datetime, subscriptionType }) {
28
+ let subscription = await Subscription.query().findOne({ from, to });
29
29
  if (subscription) {
30
30
  return subscription;
31
31
  }
32
32
  subscription = await Subscription.query().insert({
33
- publicKey, from, to, datetime, subscriptionType
33
+ from, to, datetime, subscriptionType
34
34
  });
35
- console.log('Inserted subscription: ', publicKey);
35
+ console.log('Inserted subscription: ', from, to);
36
36
  return subscription;
37
37
  }
38
38
  async format() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.76",
3
+ "version": "0.0.78",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function(knex) {
6
+ return knex.schema.alterTable('subscriptions', table => {
7
+ table.string('publicKey').notNullable().alter();
8
+ });
9
+ };
10
+
11
+ /**
12
+ * @param { import("knex").Knex } knex
13
+ * @returns { Promise<void> }
14
+ */
15
+ export const down = function(knex) {
16
+ return knex.schema.alterTable('subscriptions', table => {
17
+ table.string('publicKey').nullable().alter();
18
+ });
19
+ };
@@ -65,7 +65,7 @@ export default class Release extends Model {
65
65
  let metadataAccount = (await metaplex.nfts().findAllByMintList({mints: [releaseAccount.releaseMint]}, { commitment: 'confirmed' }))[0];
66
66
  let json
67
67
  try {
68
- json = (await axios.get(metadataAccount.uri).replace('www.','').replace('arweave.net', 'gateway.irys.xyz')).data
68
+ json = (await axios.get(metadataAccount.uri.replace('www.','').replace('arweave.net', 'gateway.irys.xyz'))).data
69
69
  } catch (error) {
70
70
  json = (await axios.get(metadataAccount.uri.replace('gateway.irys.xyz', 'arweave.net'))).data
71
71
  }
@@ -12,7 +12,7 @@ class Subscription extends Model {
12
12
  static get jsonSchema() {
13
13
  return {
14
14
  type: 'object',
15
- required: ['publicKey', 'datetime'],
15
+ required: ['datetime'],
16
16
  properties: {
17
17
  publicKey: { type: 'string' },
18
18
  datetime: { type: 'string' },
@@ -26,16 +26,16 @@ class Subscription extends Model {
26
26
  };
27
27
  }
28
28
 
29
- static async findOrCreate({publicKey, from, to, datetime, subscriptionType}) {
30
- let subscription = await Subscription.query().findOne({ publicKey });
29
+ static async findOrCreate({from, to, datetime, subscriptionType}) {
30
+ let subscription = await Subscription.query().findOne({ from, to });
31
31
  if (subscription) {
32
32
  return subscription;
33
33
  }
34
34
 
35
35
  subscription = await Subscription.query().insert({
36
- publicKey, from, to, datetime, subscriptionType
36
+ from, to, datetime, subscriptionType
37
37
  });
38
- console.log('Inserted subscription: ', publicKey)
38
+ console.log('Inserted subscription: ', from, to)
39
39
  return subscription;
40
40
  }
41
41