@nina-protocol/nina-db 0.0.88 → 0.0.89
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.
- package/dist/models/Release.js +17 -1
- package/package.json +2 -1
- package/src/models/Release.js +21 -1
package/dist/models/Release.js
CHANGED
|
@@ -9,6 +9,7 @@ import Post from './Post.js';
|
|
|
9
9
|
import Tag from './Tag.js';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import { customAlphabet } from 'nanoid';
|
|
12
|
+
import promiseRetry from 'promise-retry';
|
|
12
13
|
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
13
14
|
const randomStringGenerator = customAlphabet(alphabet, 12);
|
|
14
15
|
export default class Release extends Model {
|
|
@@ -55,7 +56,22 @@ export default class Release extends Model {
|
|
|
55
56
|
const provider = new anchor.AnchorProvider(connection, {}, { commitment: 'confirmed' });
|
|
56
57
|
const program = await anchor.Program.at(process.env.NINA_PROGRAM_ID, provider);
|
|
57
58
|
const metaplex = new Metaplex(connection);
|
|
58
|
-
|
|
59
|
+
let attempts = 0;
|
|
60
|
+
const releaseAccount = await promiseRetry(async (retry) => {
|
|
61
|
+
try {
|
|
62
|
+
attempts += 1;
|
|
63
|
+
const result = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed');
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.log('error fetching release account', error);
|
|
68
|
+
retry(error);
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
retries: 50,
|
|
72
|
+
minTimeout: 500,
|
|
73
|
+
maxTimeout: 1500,
|
|
74
|
+
});
|
|
59
75
|
let metadataAccount = (await metaplex.nfts().findAllByMintList({ mints: [releaseAccount.releaseMint] }, { commitment: 'confirmed' }))[0];
|
|
60
76
|
if (!metadataAccount) {
|
|
61
77
|
throw new Error('No metadata account found for release - is not a complete release');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nina-protocol/nina-db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.89",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "src/index.js",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"nanoid": "^4.0.2",
|
|
30
30
|
"objection": "2.2.15",
|
|
31
31
|
"pg": "^8.7.3",
|
|
32
|
+
"promise-retry": "^2.0.1",
|
|
32
33
|
"striptags": "^3.2.0",
|
|
33
34
|
"twitter-api-v2": "^1.12.9"
|
|
34
35
|
},
|
package/src/models/Release.js
CHANGED
|
@@ -9,6 +9,8 @@ import Post from './Post.js';
|
|
|
9
9
|
import Tag from './Tag.js';
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import { customAlphabet } from 'nanoid';
|
|
12
|
+
import promiseRetry from 'promise-retry';
|
|
13
|
+
|
|
12
14
|
const alphabet = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
13
15
|
const randomStringGenerator = customAlphabet(alphabet, 12);
|
|
14
16
|
|
|
@@ -62,7 +64,25 @@ export default class Release extends Model {
|
|
|
62
64
|
provider,
|
|
63
65
|
)
|
|
64
66
|
const metaplex = new Metaplex(connection);
|
|
65
|
-
|
|
67
|
+
let attempts = 0;
|
|
68
|
+
|
|
69
|
+
const releaseAccount = await promiseRetry(
|
|
70
|
+
async (retry) => {
|
|
71
|
+
try {
|
|
72
|
+
attempts += 1
|
|
73
|
+
const result = await program.account.release.fetch(new anchor.web3.PublicKey(publicKey), 'confirmed')
|
|
74
|
+
return result
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.log('error fetching release account', error)
|
|
77
|
+
retry(error)
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
retries: 50,
|
|
81
|
+
minTimeout: 500,
|
|
82
|
+
maxTimeout: 1500,
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
|
|
66
86
|
let metadataAccount = (await metaplex.nfts().findAllByMintList({mints: [releaseAccount.releaseMint]}, { commitment: 'confirmed' }))[0];
|
|
67
87
|
if (!metadataAccount) {
|
|
68
88
|
throw new Error('No metadata account found for release - is not a complete release')
|