@nina-protocol/nina-db 0.0.81 → 0.0.83

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.
@@ -8,6 +8,7 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
+ import promiseRetry from 'promise-retry';
11
12
  import { customAlphabet } from 'nanoid';
12
13
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
13
14
  const randomStringGenerator = customAlphabet(alphabet, 12);
@@ -54,7 +55,22 @@ export default class Release extends Model {
54
55
  const provider = new anchor.AnchorProvider(connection, {}, { commitment: 'confirmed' });
55
56
  const program = await anchor.Program.at(process.env.NINA_PROGRAM_ID, provider);
56
57
  const metaplex = new Metaplex(connection);
57
- const releaseAccount = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed');
58
+ let attempts = 0;
59
+ const releaseAccount = await promiseRetry(async (retry) => {
60
+ try {
61
+ attempts += 1;
62
+ const result = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed');
63
+ return result;
64
+ }
65
+ catch (error) {
66
+ console.log('error fetching release account', error);
67
+ retry(error);
68
+ }
69
+ }, {
70
+ retries: 50,
71
+ minTimeout: 500,
72
+ maxTimeout: 1500,
73
+ });
58
74
  let metadataAccount = (await metaplex.nfts().findAllByMintList({ mints: [releaseAccount.releaseMint] }, { commitment: 'confirmed' }))[0];
59
75
  let json;
60
76
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -8,10 +8,10 @@ import Hub from './Hub.js';
8
8
  import Post from './Post.js';
9
9
  import Tag from './Tag.js';
10
10
  import axios from 'axios';
11
+ import promiseRetry from 'promise-retry';
11
12
  import { customAlphabet } from 'nanoid';
12
13
  const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
13
14
  const randomStringGenerator = customAlphabet(alphabet, 12);
14
-
15
15
  export default class Release extends Model {
16
16
  static tableName = 'releases';
17
17
 
@@ -47,7 +47,7 @@ export default class Release extends Model {
47
47
  archived: { type: 'boolean' },
48
48
  },
49
49
  }
50
-
50
+
51
51
  static findOrCreate = async (publicKey, hubPublicKey=null) => {
52
52
  let release = await Release.query().findOne({ publicKey });
53
53
  if (release) {
@@ -61,7 +61,25 @@ export default class Release extends Model {
61
61
  provider,
62
62
  )
63
63
  const metaplex = new Metaplex(connection);
64
- const releaseAccount = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed')
64
+
65
+ let attempts = 0;
66
+ const releaseAccount = await promiseRetry(
67
+ async (retry) => {
68
+ try {
69
+ attempts += 1
70
+ const result = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed')
71
+ return result
72
+ } catch (error) {
73
+ console.log('error fetching release account', error)
74
+ retry(error)
75
+ }
76
+ }, {
77
+ retries: 50,
78
+ minTimeout: 500,
79
+ maxTimeout: 1500,
80
+ }
81
+ )
82
+
65
83
  let metadataAccount = (await metaplex.nfts().findAllByMintList({mints: [releaseAccount.releaseMint]}, { commitment: 'confirmed' }))[0];
66
84
  let json
67
85
  try {
@@ -1,15 +0,0 @@
1
- /**
2
- * @param { import("knex").Knex } knex
3
- * @returns { Promise<void> }
4
- */
5
- exports.up = function(knex) {
6
-
7
- };
8
-
9
- /**
10
- * @param { import("knex").Knex } knex
11
- * @returns { Promise<void> }
12
- */
13
- exports.down = function(knex) {
14
-
15
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * @param { import("knex").Knex } knex
3
- * @returns { Promise<void> }
4
- */
5
- exports.up = function(knex) {
6
-
7
- };
8
-
9
- /**
10
- * @param { import("knex").Knex } knex
11
- * @returns { Promise<void> }
12
- */
13
- exports.down = function(knex) {
14
-
15
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * @param { import("knex").Knex } knex
3
- * @returns { Promise<void> }
4
- */
5
- exports.up = function(knex) {
6
-
7
- };
8
-
9
- /**
10
- * @param { import("knex").Knex } knex
11
- * @returns { Promise<void> }
12
- */
13
- exports.down = function(knex) {
14
-
15
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * @param { import("knex").Knex } knex
3
- * @returns { Promise<void> }
4
- */
5
- exports.up = function(knex) {
6
-
7
- };
8
-
9
- /**
10
- * @param { import("knex").Knex } knex
11
- * @returns { Promise<void> }
12
- */
13
- exports.down = function(knex) {
14
-
15
- };
@@ -1,15 +0,0 @@
1
- /**
2
- * @param { import("knex").Knex } knex
3
- * @returns { Promise<void> }
4
- */
5
- exports.up = function(knex) {
6
-
7
- };
8
-
9
- /**
10
- * @param { import("knex").Knex } knex
11
- * @returns { Promise<void> }
12
- */
13
- exports.down = function(knex) {
14
-
15
- };