@solana-mobile/dapp-store-publishing-tools 0.7.2 → 0.8.0

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/lib/CoreUtils.js CHANGED
@@ -189,20 +189,21 @@ export var truncateAddress = function(address) {
189
189
  return "".concat(address.slice(0, 4), "...").concat(address.slice(address.length - 4, address.length));
190
190
  };
191
191
  export var mintNft = function() {
192
- var _ref = _async_to_generator(function(metaplex, json, createNftInput) {
193
- var uri, txBuilder;
192
+ var _ref = _async_to_generator(function(metaplex, json, createNftInput, priorityFeeLamports) {
193
+ var uri, computeBudget, txBuilder, microLamportsPerCU;
194
194
  return _ts_generator(this, function(_state) {
195
195
  switch(_state.label){
196
196
  case 0:
197
- console.info({
198
- json: json
199
- });
200
197
  return [
201
198
  4,
202
199
  metaplex.nfts().uploadMetadata(json)
203
200
  ];
204
201
  case 1:
205
202
  uri = _state.sent().uri;
203
+ computeBudget = 250000;
204
+ if (priorityFeeLamports < 0) {
205
+ throw new Error("Priority fees cannot be negative");
206
+ }
206
207
  return [
207
208
  4,
208
209
  metaplex.nfts().builders().create(_object_spread_props(_object_spread({}, createNftInput), {
@@ -216,13 +217,14 @@ export var mintNft = function() {
216
217
  txBuilder = _state.sent();
217
218
  txBuilder.prepend({
218
219
  instruction: ComputeBudgetProgram.setComputeUnitLimit({
219
- units: 250000
220
+ units: computeBudget
220
221
  }),
221
222
  signers: []
222
223
  });
224
+ microLamportsPerCU = 1000000 * priorityFeeLamports / computeBudget;
223
225
  txBuilder.prepend({
224
226
  instruction: ComputeBudgetProgram.setComputeUnitPrice({
225
- microLamports: 2000000
227
+ microLamports: microLamportsPerCU
226
228
  }),
227
229
  signers: []
228
230
  });
@@ -233,7 +235,7 @@ export var mintNft = function() {
233
235
  }
234
236
  });
235
237
  });
236
- return function mintNft(metaplex, json, createNftInput) {
238
+ return function mintNft(metaplex, json, createNftInput, priorityFeeLamports) {
237
239
  return _ref.apply(this, arguments);
238
240
  };
239
241
  }();
@@ -151,12 +151,11 @@ export var createAppJson = function(app, publisherAddress) {
151
151
  };
152
152
  export var createApp = function() {
153
153
  var _ref = _async_to_generator(function(param, param1) {
154
- var publisherMintAddress, mintAddress, appDetails, metaplex, publisher, appJson, txBuilder;
154
+ var publisherMintAddress, mintAddress, appDetails, priorityFeeLamports, metaplex, publisher, appJson, txBuilder;
155
155
  return _ts_generator(this, function(_state) {
156
156
  switch(_state.label){
157
157
  case 0:
158
- publisherMintAddress = param.publisherMintAddress, mintAddress = param.mintAddress, appDetails = param.appDetails, metaplex = param1.metaplex, publisher = param1.publisher;
159
- debug("Minting app NFT for publisher: ".concat(publisherMintAddress.toBase58()));
158
+ publisherMintAddress = param.publisherMintAddress, mintAddress = param.mintAddress, appDetails = param.appDetails, priorityFeeLamports = param.priorityFeeLamports, metaplex = param1.metaplex, publisher = param1.publisher;
160
159
  appJson = createAppJson(appDetails, publisher.publicKey);
161
160
  validateApp(appJson);
162
161
  return [
@@ -173,7 +172,7 @@ export var createApp = function() {
173
172
  share: 100
174
173
  }
175
174
  ]
176
- })
175
+ }, priorityFeeLamports)
177
176
  ];
178
177
  case 1:
179
178
  txBuilder = _state.sent();
@@ -155,12 +155,11 @@ export var createPublisherJson = function(publisher) {
155
155
  };
156
156
  export var createPublisher = function() {
157
157
  var _ref = _async_to_generator(function(param, param1) {
158
- var mintAddress, publisherDetails, metaplex, publisherJson, txBuilder;
158
+ var mintAddress, publisherDetails, priorityFeeLamports, metaplex, publisherJson, txBuilder;
159
159
  return _ts_generator(this, function(_state) {
160
160
  switch(_state.label){
161
161
  case 0:
162
- mintAddress = param.mintAddress, publisherDetails = param.publisherDetails, metaplex = param1.metaplex;
163
- debug("Minting publisher NFT");
162
+ mintAddress = param.mintAddress, publisherDetails = param.publisherDetails, priorityFeeLamports = param.priorityFeeLamports, metaplex = param1.metaplex;
164
163
  publisherJson = createPublisherJson(publisherDetails);
165
164
  validatePublisher(publisherJson);
166
165
  return [
@@ -169,7 +168,7 @@ export var createPublisher = function() {
169
168
  isCollection: true,
170
169
  isMutable: true,
171
170
  useNewMint: mintAddress
172
- })
171
+ }, priorityFeeLamports)
173
172
  ];
174
173
  case 1:
175
174
  txBuilder = _state.sent();
@@ -652,12 +652,11 @@ export var createReleaseJson = function() {
652
652
  }();
653
653
  export var createRelease = function() {
654
654
  var _ref = _async_to_generator(function(param, param1) {
655
- var appMintAddress, releaseMintAddress, releaseDetails, appDetails, publisherDetails, publisher, metaplex, releaseJson, suppressedJson, txBuilder;
655
+ var appMintAddress, releaseMintAddress, releaseDetails, appDetails, publisherDetails, priorityFeeLamports, publisher, metaplex, releaseJson, suppressedJson, txBuilder;
656
656
  return _ts_generator(this, function(_state) {
657
657
  switch(_state.label){
658
658
  case 0:
659
- appMintAddress = param.appMintAddress, releaseMintAddress = param.releaseMintAddress, releaseDetails = param.releaseDetails, appDetails = param.appDetails, publisherDetails = param.publisherDetails, publisher = param1.publisher, metaplex = param1.metaplex;
660
- debug("Minting release NFT for: ".concat(appMintAddress.toBase58()));
659
+ appMintAddress = param.appMintAddress, releaseMintAddress = param.releaseMintAddress, releaseDetails = param.releaseDetails, appDetails = param.appDetails, publisherDetails = param.publisherDetails, priorityFeeLamports = param.priorityFeeLamports, publisher = param1.publisher, metaplex = param1.metaplex;
661
660
  return [
662
661
  4,
663
662
  createReleaseJson({
@@ -683,7 +682,7 @@ export var createRelease = function() {
683
682
  }
684
683
  ],
685
684
  isMutable: false
686
- })
685
+ }, priorityFeeLamports)
687
686
  ];
688
687
  case 2:
689
688
  txBuilder = _state.sent();
@@ -223,9 +223,9 @@ export var publishUpdate = function() {
223
223
  ];
224
224
  case 1:
225
225
  updateRequest = _state.sent();
226
- submitRequestToSolanaDappPublisherPortal(updateRequest, URL_FORM_UPDATE, dryRun);
227
226
  return [
228
- 2
227
+ 2,
228
+ submitRequestToSolanaDappPublisherPortal(updateRequest, URL_FORM_UPDATE, dryRun)
229
229
  ];
230
230
  }
231
231
  });
@@ -161,7 +161,6 @@ export var submitRequestToSolanaDappPublisherPortal = function() {
161
161
  },
162
162
  data: JSON.stringify(request)
163
163
  };
164
- console.info("Sending dApp publisher portal request:", config);
165
164
  if (!!dryRun) return [
166
165
  3,
167
166
  2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana-mobile/dapp-store-publishing-tools",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
package/src/CoreUtils.ts CHANGED
@@ -24,10 +24,15 @@ type JsonMetadataMetaplexFile = Omit<JsonMetadata, "image"> & {
24
24
  export const mintNft = async (
25
25
  metaplex: Metaplex,
26
26
  json: JsonMetadataMetaplexFile,
27
- createNftInput: Omit<CreateNftInput, "uri" | "name" | "sellerFeeBasisPoints">
27
+ createNftInput: Omit<CreateNftInput, "uri" | "name" | "sellerFeeBasisPoints">,
28
+ priorityFeeLamports: number,
28
29
  ): Promise<TransactionBuilder> => {
29
- console.info({ json });
30
30
  const { uri } = await metaplex.nfts().uploadMetadata(json);
31
+ const computeBudget = 250000
32
+
33
+ if (priorityFeeLamports < 0) {
34
+ throw new Error("Priority fees cannot be negative")
35
+ }
31
36
 
32
37
  const txBuilder = await metaplex
33
38
  .nfts()
@@ -42,14 +47,16 @@ export const mintNft = async (
42
47
 
43
48
  txBuilder.prepend({
44
49
  instruction: ComputeBudgetProgram.setComputeUnitLimit({
45
- units: 250000,
50
+ units: computeBudget,
46
51
  }),
47
52
  signers: [],
48
53
  });
49
54
 
55
+ const microLamportsPerCU = 1000000 * priorityFeeLamports / computeBudget
56
+
50
57
  txBuilder.prepend({
51
58
  instruction: ComputeBudgetProgram.setComputeUnitPrice({
52
- microLamports: 2000000,
59
+ microLamports: microLamportsPerCU,
53
60
  }),
54
61
  signers: [],
55
62
  });
@@ -38,25 +38,29 @@ type CreateAppInput = {
38
38
  publisherMintAddress: PublicKey;
39
39
  mintAddress: Signer;
40
40
  appDetails: App;
41
+ priorityFeeLamports: number;
41
42
  };
42
43
 
43
44
  export const createApp = async (
44
- { publisherMintAddress, mintAddress, appDetails }: CreateAppInput,
45
+ { publisherMintAddress, mintAddress, appDetails, priorityFeeLamports }: CreateAppInput,
45
46
  { metaplex, publisher }: Context
46
47
  ) => {
47
- debug(`Minting app NFT for publisher: ${publisherMintAddress.toBase58()}`);
48
-
49
48
  const appJson = createAppJson(appDetails, publisher.publicKey);
50
49
  validateApp(appJson);
51
50
 
52
- const txBuilder = await mintNft(metaplex, appJson, {
53
- useNewMint: mintAddress,
54
- collection: publisherMintAddress,
55
- collectionAuthority: publisher,
56
- isCollection: true,
57
- isMutable: true,
58
- creators: [{ address: publisher.publicKey, share: 100 }],
59
- });
51
+ const txBuilder = await mintNft(
52
+ metaplex,
53
+ appJson,
54
+ {
55
+ useNewMint: mintAddress,
56
+ collection: publisherMintAddress,
57
+ collectionAuthority: publisher,
58
+ isCollection: true,
59
+ isMutable: true,
60
+ creators: [{ address: publisher.publicKey, share: 100 }],
61
+ },
62
+ priorityFeeLamports
63
+ );
60
64
 
61
65
  txBuilder.append(
62
66
  metaplex.nfts().builders().verifyCreator({
@@ -42,22 +42,26 @@ export const createPublisherJson = (
42
42
  type CreatePublisherInput = {
43
43
  mintAddress: Signer;
44
44
  publisherDetails: Publisher;
45
+ priorityFeeLamports: number;
45
46
  };
46
47
 
47
48
  export const createPublisher = async (
48
- { mintAddress, publisherDetails }: CreatePublisherInput,
49
+ { mintAddress, publisherDetails, priorityFeeLamports }: CreatePublisherInput,
49
50
  { metaplex }: Context
50
51
  ): Promise<TransactionBuilder> => {
51
- debug(`Minting publisher NFT`);
52
-
53
52
  const publisherJson = createPublisherJson(publisherDetails);
54
53
  validatePublisher(publisherJson);
55
54
 
56
- const txBuilder = await mintNft(metaplex, publisherJson, {
57
- isCollection: true,
58
- isMutable: true,
59
- useNewMint: mintAddress,
60
- });
55
+ const txBuilder = await mintNft(
56
+ metaplex,
57
+ publisherJson,
58
+ {
59
+ isCollection: true,
60
+ isMutable: true,
61
+ useNewMint: mintAddress,
62
+ },
63
+ priorityFeeLamports
64
+ );
61
65
 
62
66
  return txBuilder;
63
67
  };
@@ -161,6 +161,7 @@ type CreateReleaseInput = {
161
161
  releaseDetails: Release;
162
162
  publisherDetails: Publisher;
163
163
  appDetails: App;
164
+ priorityFeeLamports: number;
164
165
  };
165
166
 
166
167
  export const createRelease = async (
@@ -170,11 +171,10 @@ export const createRelease = async (
170
171
  releaseDetails,
171
172
  appDetails,
172
173
  publisherDetails,
174
+ priorityFeeLamports,
173
175
  }: CreateReleaseInput,
174
176
  { publisher, metaplex }: Context
175
177
  ) => {
176
- debug(`Minting release NFT for: ${appMintAddress.toBase58()}`);
177
-
178
178
  const releaseJson = await createReleaseJson(
179
179
  { releaseDetails, appDetails, publisherDetails },
180
180
  publisher.publicKey
@@ -183,13 +183,17 @@ export const createRelease = async (
183
183
  const suppressedJson = JSON.stringify(releaseJson, metaplexFileReplacer, 2);
184
184
  validateRelease(JSON.parse(suppressedJson));
185
185
 
186
- const txBuilder = await mintNft(metaplex, releaseJson, {
187
- useNewMint: releaseMintAddress,
188
- collection: appMintAddress,
189
- collectionAuthority: publisher,
190
- creators: [{ address: publisher.publicKey, share: 100 }],
191
- isMutable: false,
192
- });
186
+ const txBuilder = await mintNft(
187
+ metaplex,
188
+ releaseJson, {
189
+ useNewMint: releaseMintAddress,
190
+ collection: appMintAddress,
191
+ collectionAuthority: publisher,
192
+ creators: [{ address: publisher.publicKey, share: 100 }],
193
+ isMutable: false,
194
+ },
195
+ priorityFeeLamports
196
+ );
193
197
 
194
198
  // TODO(jon): Enable a case where the signer is not the publisher
195
199
  // TODO(jon): Allow this to be unverified and to verify later
@@ -140,5 +140,5 @@ export const publishUpdate = async (
140
140
  requestorIsAuthorized,
141
141
  criticalUpdate);
142
142
 
143
- submitRequestToSolanaDappPublisherPortal(updateRequest, URL_FORM_UPDATE, dryRun);
143
+ return submitRequestToSolanaDappPublisherPortal(updateRequest, URL_FORM_UPDATE, dryRun);
144
144
  };
@@ -43,8 +43,6 @@ export const submitRequestToSolanaDappPublisherPortal = async (
43
43
  data: JSON.stringify(request),
44
44
  } as AxiosRequestConfig;
45
45
 
46
- console.info("Sending dApp publisher portal request:", config);
47
-
48
46
  if (!dryRun) {
49
47
  await axios(config)
50
48
  .then((response) => {