@imtbl/sdk 1.35.1-alpha → 1.35.2-alpha.1

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/index.cjs CHANGED
@@ -184,7 +184,7 @@ const flattenProperties$1 = (properties) => {
184
184
  };
185
185
 
186
186
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
187
- const SDK_VERSION$1 = '1.35.1-alpha';
187
+ const SDK_VERSION$1 = '1.35.2-alpha.1';
188
188
  const getFrameParentDomain$1 = () => {
189
189
  if (isNode$1()) {
190
190
  return '';
@@ -14211,7 +14211,7 @@ class MultiRollupApiClients {
14211
14211
  }
14212
14212
 
14213
14213
  // eslint-disable-next-line @typescript-eslint/naming-convention
14214
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.35.1-alpha' };
14214
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.35.2-alpha.1' };
14215
14215
  const createConfig$1 = ({ basePath, headers, }) => {
14216
14216
  if (!basePath.trim()) {
14217
14217
  throw Error('basePath can not be empty');
@@ -14283,7 +14283,7 @@ class APIError extends Error {
14283
14283
 
14284
14284
  /* eslint-disable implicit-arrow-linebreak */
14285
14285
  const defaultHeaders$1 = {
14286
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.35.1-alpha',
14286
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.35.2-alpha.1',
14287
14287
  };
14288
14288
  /**
14289
14289
  * createAPIConfiguration to create a custom Configuration
@@ -14757,7 +14757,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14757
14757
  /* eslint-disable @typescript-eslint/naming-convention */
14758
14758
  class ApiConfiguration extends index$2.Configuration {
14759
14759
  }
14760
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.35.1-alpha' };
14760
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.35.2-alpha.1' };
14761
14761
  /**
14762
14762
  * @dev use createImmutableXConfiguration instead
14763
14763
  */
@@ -14796,7 +14796,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14796
14796
  chainID,
14797
14797
  coreContractAddress,
14798
14798
  registrationContractAddress,
14799
- sdkVersion: 'ts-immutable-sdk-1.35.1-alpha',
14799
+ sdkVersion: 'ts-immutable-sdk-1.35.2-alpha.1',
14800
14800
  baseConfig,
14801
14801
  });
14802
14802
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -26376,6 +26376,7 @@ const getOverlay = (contents) => `
26376
26376
  height: 100% !important;
26377
26377
  background: rgba(13, 13, 13, 0.48) !important;
26378
26378
  backdrop-filter: blur(28px) !important;
26379
+ -webkit-backdrop-filter: blur(28px) !important;
26379
26380
  display: flex !important;
26380
26381
  flex-direction: column !important;
26381
26382
  justify-content: center !important;
@@ -26404,6 +26405,19 @@ const getOverlay = (contents) => `
26404
26405
  </div>
26405
26406
  </div>
26406
26407
  `;
26408
+ function addLink({ id, href, rel, crossOrigin, }) {
26409
+ const fullId = `${PASSPORT_OVERLAY_ID}-${id}`;
26410
+ if (!document.getElementById(fullId)) {
26411
+ const link = document.createElement('link');
26412
+ link.id = fullId;
26413
+ link.href = href;
26414
+ if (rel)
26415
+ link.rel = rel;
26416
+ if (crossOrigin)
26417
+ link.crossOrigin = crossOrigin;
26418
+ document.head.appendChild(link);
26419
+ }
26420
+ }
26407
26421
  const getBlockedOverlay = () => getOverlay(getBlockedContents());
26408
26422
  const getGenericOverlay = () => getOverlay(getGenericContents());
26409
26423
 
@@ -26445,6 +26459,9 @@ class Overlay {
26445
26459
  }
26446
26460
  appendOverlay() {
26447
26461
  if (!this.overlay) {
26462
+ addLink({ id: 'link-googleapis', href: 'https://fonts.googleapis.com' });
26463
+ addLink({ id: 'link-gstatic', href: 'https://fonts.gstatic.com', crossOrigin: 'anonymous' });
26464
+ addLink({ id: 'link-roboto', href: 'https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap', rel: 'stylesheet' });
26448
26465
  const overlay = document.createElement('div');
26449
26466
  overlay.innerHTML = this.isBlockedOverlay ? getBlockedOverlay() : getGenericOverlay();
26450
26467
  document.body.insertAdjacentElement('beforeend', overlay);
@@ -58116,7 +58133,7 @@ const flattenProperties = (properties) => {
58116
58133
  };
58117
58134
 
58118
58135
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
58119
- const SDK_VERSION = '1.35.1-alpha';
58136
+ const SDK_VERSION = '1.35.2-alpha.1';
58120
58137
  const getFrameParentDomain = () => {
58121
58138
  if (isNode()) {
58122
58139
  return '';
@@ -63409,7 +63426,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
63409
63426
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
63410
63427
  };
63411
63428
 
63412
- const SDK_VERSION_MARKER = '1.35.1-alpha';
63429
+ const SDK_VERSION_MARKER = '1.35.2-alpha.1';
63413
63430
  // This SDK version is replaced by the `yarn build` command ran on the root level
63414
63431
  const globalPackageVersion = () => SDK_VERSION_MARKER;
63415
63432
 
@@ -69082,7 +69099,7 @@ const init = async (body, env, handlers) => {
69082
69099
  return reject(err);
69083
69100
  }
69084
69101
  // check for topic arn prefix
69085
- if (!message.TopicArn.startsWith(allowedTopicArnPrefix[env])) {
69102
+ if (!msg.TopicArn.startsWith(allowedTopicArnPrefix[env])) {
69086
69103
  throw new Error('Invalid topic arn');
69087
69104
  }
69088
69105
  if (message?.Type === 'SubscriptionConfirmation') {
@@ -69115,7 +69132,27 @@ var webhook = /*#__PURE__*/Object.freeze({
69115
69132
  init: init
69116
69133
  });
69117
69134
 
69118
- const mintingPersistence$1 = (client) => ({
69135
+ /* eslint-disable no-console */
69136
+ /* eslint-disable global-require */
69137
+ let optionalPackage = null;
69138
+ let pgClient = null;
69139
+ try {
69140
+ optionalPackage = require('pg');
69141
+ pgClient = new optionalPackage.Pool({
69142
+ user: process.env.PG_USER || 'postgres',
69143
+ host: process.env.PG_HOST || 'localhost',
69144
+ database: process.env.PG_DB_NAME || 'nullus',
69145
+ password: process.env.PG_PASSWORD || 'postgres',
69146
+ port: parseInt(process.env.PG_PORT || '5432', 10) || 5432,
69147
+ });
69148
+ }
69149
+ catch (error) {
69150
+ console.error('pg is not installed. Please install it by running `npm install pg`');
69151
+ optionalPackage = null;
69152
+ }
69153
+ const client = pgClient;
69154
+
69155
+ const mintingPersistence = {
69119
69156
  recordMint: async (request) => {
69120
69157
  const r = await client.query(`
69121
69158
  INSERT INTO im_assets (asset_id, contract_address, owner_address, metadata)
@@ -69183,7 +69220,7 @@ const mintingPersistence$1 = (client) => ({
69183
69220
  },
69184
69221
  resetMintingStatus: async (ids) => {
69185
69222
  await client.query(`
69186
- UPDATE im_assets SET minting_status = null WHERE id = ANY($1);
69223
+ UPDATE im_assets SET minting_status = null WHERE id = ANY($1) and contract_address = $2;
69187
69224
  `, [ids]);
69188
69225
  },
69189
69226
  markForRetry: async (ids) => {
@@ -69201,216 +69238,9 @@ const mintingPersistence$1 = (client) => ({
69201
69238
  const res = await client.query(`
69202
69239
  SELECT * FROM im_assets WHERE contract_address = $1 and asset_id = $2;
69203
69240
  `, [contractAddress, referenceId]);
69204
- return res.rows[0] || null;
69241
+ return res.rows[0];
69205
69242
  }
69206
- });
69207
-
69208
- // client is a PrismaClient instance. it needs to be generated with
69209
- // additional schema defined inside (TODO: point to repo) file.
69210
- const mintingPersistence = (client) => ({
69211
- recordMint: async (request) => {
69212
- const result = await client.imAssets.upsert({
69213
- where: {
69214
- im_assets_uindex: {
69215
- assetId: request.asset_id, contractAddress: request.contract_address
69216
- }
69217
- },
69218
- update: {},
69219
- create: {
69220
- assetId: request.asset_id,
69221
- contractAddress: request.contract_address,
69222
- ownerAddress: request.owner_address,
69223
- metadata: JSON.stringify(request.metadata), // Serialize JSON metadata
69224
- },
69225
- });
69226
- // Since upsert does not throw on update and does not tell directly if it updated or inserted,
69227
- // we need to add additional logic to handle this if "result" does not provide enough info.
69228
- if (!result) {
69229
- throw new Error('Duplicated mint');
69230
- }
69231
- },
69232
- // WARNING: this is NOT concurrency safe. Please only call this method one at a time.
69233
- getNextBatchForSubmission: async (limit) => {
69234
- const assets = await client.imAssets.findMany({
69235
- where: {
69236
- mintingStatus: null
69237
- },
69238
- take: limit
69239
- });
69240
- const assetIds = assets.map((asset) => asset.id);
69241
- await client.imAssets.updateMany({
69242
- where: {
69243
- id: {
69244
- in: assetIds
69245
- }
69246
- },
69247
- data: {
69248
- mintingStatus: 'submitting'
69249
- }
69250
- });
69251
- const updatedAssets = await client.imAssets.findMany({
69252
- where: {
69253
- id: {
69254
- in: assetIds
69255
- }
69256
- }
69257
- });
69258
- return updatedAssets.map((asset) => ({
69259
- id: asset.id,
69260
- contract_address: asset.contractAddress,
69261
- wallet_address: asset.ownerAddress,
69262
- asset_id: asset.assetId,
69263
- metadata: asset.metadata ? JSON.parse(asset.metadata) : null,
69264
- owner_address: asset.ownerAddress,
69265
- tried_count: asset.triedCount,
69266
- }));
69267
- },
69268
- updateMintingStatusToSubmitted: async (ids) => {
69269
- await client.imAssets.updateMany({
69270
- where: {
69271
- id: {
69272
- in: ids
69273
- }
69274
- },
69275
- data: {
69276
- mintingStatus: 'submitted'
69277
- }
69278
- });
69279
- },
69280
- syncMintingStatus: async (submittedMintRequest) => {
69281
- // First, attempt to retrieve the existing asset
69282
- const existingAsset = await client.imAssets.findUnique({
69283
- where: {
69284
- im_assets_uindex: {
69285
- assetId: submittedMintRequest.assetId,
69286
- contractAddress: submittedMintRequest.contractAddress,
69287
- },
69288
- }
69289
- });
69290
- // Check if the asset exists and the condition for updating is met
69291
- if (existingAsset && (existingAsset.lastImtblZkevmMintRequestUpdatedId === null
69292
- || existingAsset.lastImtblZkevmMintRequestUpdatedId < submittedMintRequest.imtblZkevmMintRequestUpdatedId)) {
69293
- // Perform update if the existing record's lastImtblZkevmMintRequestUpdatedId is less than the new one or is null
69294
- await client.imAssets.update({
69295
- where: {
69296
- im_assets_uindex: {
69297
- assetId: submittedMintRequest.assetId,
69298
- contractAddress: submittedMintRequest.contractAddress,
69299
- },
69300
- },
69301
- data: {
69302
- ownerAddress: submittedMintRequest.ownerAddress,
69303
- tokenId: submittedMintRequest.tokenId,
69304
- mintingStatus: submittedMintRequest.status,
69305
- metadataId: submittedMintRequest.metadataId,
69306
- lastImtblZkevmMintRequestUpdatedId: submittedMintRequest.imtblZkevmMintRequestUpdatedId,
69307
- error: submittedMintRequest.error,
69308
- }
69309
- });
69310
- }
69311
- else if (!existingAsset) {
69312
- // Perform insert if no existing record is found
69313
- await client.imAssets.create({
69314
- data: {
69315
- assetId: submittedMintRequest.assetId,
69316
- contractAddress: submittedMintRequest.contractAddress,
69317
- ownerAddress: submittedMintRequest.ownerAddress,
69318
- tokenId: submittedMintRequest.tokenId,
69319
- mintingStatus: submittedMintRequest.status,
69320
- metadataId: submittedMintRequest.metadataId,
69321
- lastImtblZkevmMintRequestUpdatedId: submittedMintRequest.imtblZkevmMintRequestUpdatedId,
69322
- error: submittedMintRequest.error,
69323
- }
69324
- });
69325
- }
69326
- // If existing asset does not meet the update condition, do nothing
69327
- },
69328
- updateMintingStatusToSubmissionFailed: async (ids) => {
69329
- await client.imAssets.updateMany({
69330
- where: {
69331
- id: {
69332
- in: ids
69333
- }
69334
- },
69335
- data: {
69336
- mintingStatus: 'submission_failed'
69337
- }
69338
- });
69339
- },
69340
- markAsConflict: async (assetIds, contractAddress) => {
69341
- await client.imAssets.updateMany({
69342
- where: {
69343
- assetId: {
69344
- in: assetIds // Targets assets where assetId is in the provided list
69345
- },
69346
- contractAddress // Additional condition for contract address
69347
- },
69348
- data: {
69349
- mintingStatus: 'conflicting' // Set the new status
69350
- }
69351
- });
69352
- },
69353
- resetMintingStatus: async (ids) => {
69354
- await client.imAssets.updateMany({
69355
- where: {
69356
- id: {
69357
- in: ids // Condition to match ids
69358
- }
69359
- },
69360
- data: {
69361
- mintingStatus: null // Setting minting_status to null
69362
- }
69363
- });
69364
- },
69365
- // this method is not concurrency safe
69366
- markForRetry: async (ids) => {
69367
- // Retrieve the current values of tried_count for the specified ids
69368
- const assets = await client.imAssets.findMany({
69369
- where: {
69370
- id: {
69371
- in: ids
69372
- }
69373
- },
69374
- select: {
69375
- id: true,
69376
- triedCount: true // Assuming the field is named triedCount
69377
- }
69378
- });
69379
- // Update each asset with the new tried_count and nullify minting_status
69380
- for (const asset of assets) {
69381
- await client.imAssets.update({
69382
- where: {
69383
- id: asset.id
69384
- },
69385
- data: {
69386
- mintingStatus: null,
69387
- triedCount: asset.triedCount + 1
69388
- }
69389
- });
69390
- }
69391
- },
69392
- getMintingRequest: async (contractAddress, referenceId) => {
69393
- // Retrieve the asset from the database based on contract_address and asset_id
69394
- const asset = await client.imAssets.findFirst({
69395
- where: {
69396
- contractAddress,
69397
- assetId: referenceId
69398
- }
69399
- });
69400
- if (!asset) {
69401
- return null;
69402
- }
69403
- return {
69404
- asset_id: asset.assetId,
69405
- contract_address: asset.contractAddress,
69406
- id: asset.id,
69407
- metadata: asset.metadata ? JSON.parse(asset.metadata) : null,
69408
- owner_address: asset.ownerAddress,
69409
- tried_count: asset.triedCount,
69410
- wallet_address: asset.ownerAddress
69411
- };
69412
- }
69413
- });
69243
+ };
69414
69244
 
69415
69245
  // TODO: expose metrics
69416
69246
  // - submitting status count, conflicting status count
@@ -69430,7 +69260,7 @@ const submitMintingRequests = async (mintingPersistence, blockchainDataSDKClient
69430
69260
  await new Promise((resolve) => {
69431
69261
  setTimeout(resolve, defaultMintingDelay);
69432
69262
  });
69433
- let batchSize = Math.min(mintingResponse?.imx_remaining_mint_requests
69263
+ let batchSize = Math.min(mintingResponse
69434
69264
  ? parseInt(mintingResponse.imx_remaining_mint_requests, 10)
69435
69265
  : defaultBatchSize, defaultBatchSize);
69436
69266
  if (batchSize === 0
@@ -69563,8 +69393,7 @@ const processMint = async (mintingPersistence, event, logger = console) => {
69563
69393
 
69564
69394
  var minting_backend = /*#__PURE__*/Object.freeze({
69565
69395
  __proto__: null,
69566
- mintingPersistencePg: mintingPersistence$1,
69567
- mintingPersistencePrismaSqlite: mintingPersistence,
69396
+ mintingPersistencePg: mintingPersistence,
69568
69397
  processMint: processMint,
69569
69398
  recordMint: recordMint,
69570
69399
  submitMintingRequests: submitMintingRequests
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  /// <reference types="node" />
2
- import { Pool } from 'pg';
3
-
4
2
  declare enum Environment {
5
3
  PRODUCTION = "production",
6
4
  SANDBOX = "sandbox"
@@ -29383,18 +29381,16 @@ type SubmittedMintRequest = {
29383
29381
  interface MintingPersistence {
29384
29382
  recordMint: (request: CreateMintRequest) => Promise<void>;
29385
29383
  getNextBatchForSubmission: (limit: number) => Promise<MintRequest[]>;
29386
- updateMintingStatusToSubmitted: (ids: string[]) => Promise<void>;
29387
- updateMintingStatusToSubmissionFailed: (ids: string[]) => Promise<void>;
29384
+ updateMintingStatusToSubmitted: (id: string[]) => Promise<void>;
29385
+ updateMintingStatusToSubmissionFailed: (id: string[]) => Promise<void>;
29388
29386
  syncMintingStatus: (submittedMintRequest: SubmittedMintRequest) => Promise<void>;
29389
29387
  markAsConflict: (assetIds: string[], contractAddress: string) => Promise<void>;
29390
29388
  resetMintingStatus: (ids: string[]) => Promise<void>;
29391
29389
  markForRetry: (ids: string[]) => Promise<void>;
29392
- getMintingRequest: (contractAddress: string, referenceId: string) => Promise<MintRequest | null>;
29390
+ getMintingRequest: (contractAddress: string, referenceId: string) => Promise<MintRequest>;
29393
29391
  }
29394
29392
 
29395
- declare const mintingPersistence$1: (client: Pool) => MintingPersistence;
29396
-
29397
- declare const mintingPersistence: (client: any) => MintingPersistence;
29393
+ declare const mintingPersistence: MintingPersistence;
29398
29394
 
29399
29395
  interface Logger {
29400
29396
  info: (message: string) => void;
@@ -29439,8 +29435,7 @@ declare const minting_backend_d_recordMint: typeof recordMint;
29439
29435
  declare const minting_backend_d_submitMintingRequests: typeof submitMintingRequests;
29440
29436
  declare namespace minting_backend_d {
29441
29437
  export {
29442
- mintingPersistence$1 as mintingPersistencePg,
29443
- mintingPersistence as mintingPersistencePrismaSqlite,
29438
+ mintingPersistence as mintingPersistencePg,
29444
29439
  minting_backend_d_processMint as processMint,
29445
29440
  minting_backend_d_recordMint as recordMint,
29446
29441
  minting_backend_d_submitMintingRequests as submitMintingRequests,