@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.
- package/dist/models/Release.js +17 -1
- package/package.json +1 -1
- package/src/models/Release.js +21 -3
- package/src/node_modules/@nina-protocol/nina-db/dist/migrations/20230306215736_add_hub_updated_at.js +0 -15
- package/src/node_modules/@nina-protocol/nina-db/dist/migrations/20231031200439_add_profile.js +0 -15
- package/src/node_modules/@nina-protocol/nina-db/dist/migrations/20231112031833_post_version.js +0 -15
- package/src/node_modules/@nina-protocol/nina-db/dist/migrations/20231112031850_post_version.js +0 -15
- package/src/node_modules/@nina-protocol/nina-db/dist/migrations/20231116215059_add_tags.js +0 -15
- package/yarn-error.log +0 -6817
package/dist/models/Release.js
CHANGED
|
@@ -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
|
-
|
|
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
package/src/models/Release.js
CHANGED
|
@@ -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
|
-
|
|
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 {
|