@imtbl/sdk 1.33.0 → 1.34.0-alpha

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
@@ -34,6 +34,7 @@ var solidity = require('@ethersproject/solidity');
34
34
  var routerSdk = require('@uniswap/router-sdk');
35
35
  var units = require('@ethersproject/units');
36
36
  var bignumber = require('@ethersproject/bignumber');
37
+ var MessageValidator = require('sns-validator');
37
38
 
38
39
  function _interopNamespaceDefault(e) {
39
40
  var n = Object.create(null);
@@ -183,7 +184,7 @@ const flattenProperties$1 = (properties) => {
183
184
  };
184
185
 
185
186
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
186
- const SDK_VERSION$1 = '1.33.0';
187
+ const SDK_VERSION$1 = '1.34.0-alpha';
187
188
  const getFrameParentDomain$1 = () => {
188
189
  if (isNode$1()) {
189
190
  return '';
@@ -14210,7 +14211,7 @@ class MultiRollupApiClients {
14210
14211
  }
14211
14212
 
14212
14213
  // eslint-disable-next-line @typescript-eslint/naming-convention
14213
- const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.33.0' };
14214
+ const defaultHeaders$2 = { 'x-sdk-version': 'ts-immutable-sdk-1.34.0-alpha' };
14214
14215
  const createConfig$1 = ({ basePath, headers, }) => {
14215
14216
  if (!basePath.trim()) {
14216
14217
  throw Error('basePath can not be empty');
@@ -14282,7 +14283,7 @@ class APIError extends Error {
14282
14283
 
14283
14284
  /* eslint-disable implicit-arrow-linebreak */
14284
14285
  const defaultHeaders$1 = {
14285
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.33.0',
14286
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.34.0-alpha',
14286
14287
  };
14287
14288
  /**
14288
14289
  * createAPIConfiguration to create a custom Configuration
@@ -14756,7 +14757,7 @@ var blockchain_data = /*#__PURE__*/Object.freeze({
14756
14757
  /* eslint-disable @typescript-eslint/naming-convention */
14757
14758
  class ApiConfiguration extends index$2.Configuration {
14758
14759
  }
14759
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.33.0' };
14760
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.34.0-alpha' };
14760
14761
  /**
14761
14762
  * @dev use createImmutableXConfiguration instead
14762
14763
  */
@@ -14795,7 +14796,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
14795
14796
  chainID,
14796
14797
  coreContractAddress,
14797
14798
  registrationContractAddress,
14798
- sdkVersion: 'ts-immutable-sdk-1.33.0',
14799
+ sdkVersion: 'ts-immutable-sdk-1.34.0-alpha',
14799
14800
  baseConfig,
14800
14801
  });
14801
14802
  const production = ({ baseConfig }) => createImmutableXConfiguration({
@@ -23617,12 +23618,12 @@ function assertOptions$1(options, schema, allowUnknown) {
23617
23618
  }
23618
23619
  }
23619
23620
 
23620
- var validator$1 = {
23621
+ var validator$2 = {
23621
23622
  assertOptions: assertOptions$1,
23622
23623
  validators: validators$1$1
23623
23624
  };
23624
23625
 
23625
- const validators$2 = validator$1.validators;
23626
+ const validators$2 = validator$2.validators;
23626
23627
 
23627
23628
  /**
23628
23629
  * Create a new instance of Axios
@@ -23663,7 +23664,7 @@ let Axios$2 = class Axios {
23663
23664
  const {transitional, paramsSerializer, headers} = config;
23664
23665
 
23665
23666
  if (transitional !== undefined) {
23666
- validator$1.assertOptions(transitional, {
23667
+ validator$2.assertOptions(transitional, {
23667
23668
  silentJSONParsing: validators$2.transitional(validators$2.boolean),
23668
23669
  forcedJSONParsing: validators$2.transitional(validators$2.boolean),
23669
23670
  clarifyTimeoutError: validators$2.transitional(validators$2.boolean)
@@ -23676,7 +23677,7 @@ let Axios$2 = class Axios {
23676
23677
  serialize: paramsSerializer
23677
23678
  };
23678
23679
  } else {
23679
- validator$1.assertOptions(paramsSerializer, {
23680
+ validator$2.assertOptions(paramsSerializer, {
23680
23681
  encode: validators$2.function,
23681
23682
  serialize: validators$2.function
23682
23683
  }, true);
@@ -32269,12 +32270,12 @@ function assertOptions(options, schema, allowUnknown) {
32269
32270
  }
32270
32271
  }
32271
32272
 
32272
- var validator = {
32273
+ var validator$1 = {
32273
32274
  assertOptions,
32274
32275
  validators: validators$1
32275
32276
  };
32276
32277
 
32277
- const validators = validator.validators;
32278
+ const validators = validator$1.validators;
32278
32279
 
32279
32280
  /**
32280
32281
  * Create a new instance of Axios
@@ -32315,7 +32316,7 @@ class Axios {
32315
32316
  const {transitional, paramsSerializer, headers} = config;
32316
32317
 
32317
32318
  if (transitional !== undefined) {
32318
- validator.assertOptions(transitional, {
32319
+ validator$1.assertOptions(transitional, {
32319
32320
  silentJSONParsing: validators.transitional(validators.boolean),
32320
32321
  forcedJSONParsing: validators.transitional(validators.boolean),
32321
32322
  clarifyTimeoutError: validators.transitional(validators.boolean)
@@ -32328,7 +32329,7 @@ class Axios {
32328
32329
  serialize: paramsSerializer
32329
32330
  };
32330
32331
  } else {
32331
- validator.assertOptions(paramsSerializer, {
32332
+ validator$1.assertOptions(paramsSerializer, {
32332
32333
  encode: validators.function,
32333
32334
  serialize: validators.function
32334
32335
  }, true);
@@ -57957,7 +57958,7 @@ const flattenProperties = (properties) => {
57957
57958
  };
57958
57959
 
57959
57960
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
57960
- const SDK_VERSION = '1.33.0';
57961
+ const SDK_VERSION = '1.34.0-alpha';
57961
57962
  const getFrameParentDomain = () => {
57962
57963
  if (isNode()) {
57963
57964
  return '';
@@ -63179,7 +63180,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
63179
63180
  maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
63180
63181
  };
63181
63182
 
63182
- const SDK_VERSION_MARKER = '1.33.0';
63183
+ const SDK_VERSION_MARKER = '1.34.0-alpha';
63183
63184
  // This SDK version is replaced by the `yarn build` command ran on the root level
63184
63185
  const globalPackageVersion = () => SDK_VERSION_MARKER;
63185
63186
 
@@ -68709,9 +68710,323 @@ var x = /*#__PURE__*/Object.freeze({
68709
68710
  sandbox: sandbox
68710
68711
  });
68711
68712
 
68713
+ const validator = new MessageValidator();
68714
+ const allowedTopicArnPrefix = {
68715
+ [Environment$1.PRODUCTION]: 'arn:aws:sns:us-east-2:362750628221:',
68716
+ [Environment$1.SANDBOX]: 'arn:aws:sns:us-east-2:783421985614:'
68717
+ };
68718
+ const init = async (body, env, handlers) => {
68719
+ const msg = await new Promise((resolve, reject) => {
68720
+ validator.validate(body, (err, message) => {
68721
+ if (err) {
68722
+ return reject(err);
68723
+ }
68724
+ // check for topic arn prefix
68725
+ if (!msg.TopicArn.startsWith(allowedTopicArnPrefix[env])) {
68726
+ throw new Error('Invalid topic arn');
68727
+ }
68728
+ if (message?.Type === 'SubscriptionConfirmation') {
68729
+ fetch(message.SubscribeURL).then(() => {
68730
+ resolve(message);
68731
+ }).catch((e) => {
68732
+ reject(e);
68733
+ });
68734
+ }
68735
+ return resolve(message);
68736
+ });
68737
+ });
68738
+ if (msg.Type === 'Notification') {
68739
+ const event = JSON.parse(msg.Message);
68740
+ switch (event.event_name) {
68741
+ case 'imtbl_zkevm_mint_request_updated':
68742
+ await handlers.zkevmMintRequestUpdated(event);
68743
+ break;
68744
+ default:
68745
+ if (handlers.others) {
68746
+ await handlers.others(event);
68747
+ }
68748
+ break;
68749
+ }
68750
+ }
68751
+ };
68752
+
68753
+ var webhook = /*#__PURE__*/Object.freeze({
68754
+ __proto__: null,
68755
+ init: init
68756
+ });
68757
+
68758
+ /* eslint-disable no-console */
68759
+ /* eslint-disable global-require */
68760
+ let optionalPackage = null;
68761
+ let pgClient = null;
68762
+ try {
68763
+ optionalPackage = require('pg');
68764
+ pgClient = new optionalPackage.Pool({
68765
+ user: process.env.PG_USER || 'postgres',
68766
+ host: process.env.PG_HOST || 'localhost',
68767
+ database: process.env.PG_DB_NAME || 'nullus',
68768
+ password: process.env.PG_PASSWORD || 'postgres',
68769
+ port: parseInt(process.env.PG_PORT || '5432', 10) || 5432,
68770
+ });
68771
+ }
68772
+ catch (error) {
68773
+ console.error('pg is not installed. Please install it by running `npm install pg`');
68774
+ optionalPackage = null;
68775
+ }
68776
+ const client = pgClient;
68777
+
68778
+ const mintingPersistence = {
68779
+ recordMint: async (request) => {
68780
+ const r = await client.query(`
68781
+ INSERT INTO im_assets (asset_id, contract_address, owner_address, metadata)
68782
+ VALUES ($1, $2, $3, $4) ON CONFLICT (asset_id) DO NOTHING;
68783
+ `, [request.asset_id, request.contract_address, request.owner_address, request.metadata]);
68784
+ if (r.rowCount === 0) {
68785
+ throw new Error('Duplicated mint');
68786
+ }
68787
+ },
68788
+ getNextBatchForSubmission: async (limit) => {
68789
+ const res = await client.query(`
68790
+ UPDATE im_assets SET minting_status = 'submitting' WHERE minting_status IS NULL and id in (
68791
+ select id from im_assets where minting_status is null limit $1 for update skip locked
68792
+ ) returning *;
68793
+ `, [limit]);
68794
+ return res.rows;
68795
+ },
68796
+ updateMintingStatusToSubmitted: async (ids) => {
68797
+ await client.query(`
68798
+ UPDATE im_assets SET minting_status = $2 WHERE id = ANY($1);
68799
+ `, [ids, 'submitted']);
68800
+ },
68801
+ syncMintingStatus: async (submittedMintRequest) => {
68802
+ // doing a upsert just in case the row has not been created yet
68803
+ await client.query(`
68804
+ INSERT INTO im_assets (
68805
+ asset_id,
68806
+ contract_address,
68807
+ owner_address,
68808
+ token_id,
68809
+ minting_status,
68810
+ metadata_id,
68811
+ last_imtbl_zkevm_mint_request_updated_id,
68812
+ error
68813
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (asset_id, contract_address)
68814
+ DO UPDATE SET
68815
+ owner_address = $3,
68816
+ token_id = $4,
68817
+ minting_status = $5,
68818
+ metadata_id = $6,
68819
+ last_imtbl_zkevm_mint_request_updated_id = $7,
68820
+ error = $8
68821
+ where (
68822
+ im_assets.last_imtbl_zkevm_mint_request_updated_id < $7 OR
68823
+ im_assets.last_imtbl_zkevm_mint_request_updated_id is null
68824
+ );
68825
+ `, [
68826
+ submittedMintRequest.assetId,
68827
+ submittedMintRequest.contractAddress,
68828
+ submittedMintRequest.ownerAddress,
68829
+ submittedMintRequest.tokenId,
68830
+ submittedMintRequest.status,
68831
+ submittedMintRequest.metadataId,
68832
+ submittedMintRequest.imtblZkevmMintRequestUpdatedId,
68833
+ submittedMintRequest.error
68834
+ ]);
68835
+ },
68836
+ markAsConflict: async (assetIds, contractAddress) => {
68837
+ await client.query(`
68838
+ UPDATE im_assets
68839
+ SET minting_status = 'conflicting'
68840
+ WHERE asset_id = ANY($1)
68841
+ AND contract_address = $2;
68842
+ `, [assetIds, contractAddress]);
68843
+ },
68844
+ resetMintingStatus: async (ids) => {
68845
+ await client.query(`
68846
+ UPDATE im_assets SET minting_status = null WHERE id = ANY($1) and contract_address = $2;
68847
+ `, [ids]);
68848
+ },
68849
+ markForRetry: async (ids) => {
68850
+ await client.query(`
68851
+ UPDATE im_assets
68852
+ SET minting_status = null, tried_count = tried_count + 1 WHERE id = ANY($1);
68853
+ `, [ids]);
68854
+ },
68855
+ updateMintingStatusToSubmissionFailed: async (ids) => {
68856
+ await client.query(`
68857
+ UPDATE im_assets SET minting_status = 'submission_failed' WHERE id = ANY($1);
68858
+ `, [ids]);
68859
+ },
68860
+ getMintingRequest: async (contractAddress, referenceId) => {
68861
+ const res = await client.query(`
68862
+ SELECT * FROM im_assets WHERE contract_address = $1 and asset_id = $2;
68863
+ `, [contractAddress, referenceId]);
68864
+ return res.rows[0];
68865
+ }
68866
+ };
68867
+
68868
+ // TODO: expose metrics
68869
+ // - submitting status count, conflicting status count
68870
+ // - failed events count
68871
+ const recordMint = async (mintingPersistence, mintRequest) => {
68872
+ mintingPersistence.recordMint(mintRequest);
68873
+ };
68874
+ const defaultMintingDelay = 1000;
68875
+ // This function can be called in different node process and will run in parallel to mint assets.
68876
+ // Each process will NOT mint the same asset.
68877
+ // Monitor your database to see if parallel processes are saturating the database CPU and triggering excessive vacuuming.
68878
+ // default batch size will be treated as 100 when it exceeds 100 because minting API has a limit of 100 assets per request.
68879
+ const submitMintingRequests = async (mintingPersistence, blockchainDataSDKClient, { defaultBatchSize = 1000, chainName = 'imtbl-zkevm-testnet', maxNumberOfTries = 3, }, logger = console) => {
68880
+ let mintingResponse;
68881
+ // eslint-disable-next-line no-constant-condition
68882
+ while (true) {
68883
+ await new Promise((resolve) => {
68884
+ setTimeout(resolve, defaultMintingDelay);
68885
+ });
68886
+ let batchSize = Math.min(mintingResponse
68887
+ ? parseInt(mintingResponse.imx_remaining_mint_requests, 10)
68888
+ : defaultBatchSize, defaultBatchSize);
68889
+ if (batchSize === 0
68890
+ && mintingResponse
68891
+ && new Date(mintingResponse.imx_mint_requests_limit_reset) > new Date()) {
68892
+ logger.info(`minting limit reached, waiting for reset at ${mintingResponse?.imx_mint_requests_limit_reset}`);
68893
+ continue;
68894
+ }
68895
+ if (batchSize === 0) {
68896
+ logger.info(`minting limit has been reset, use default batch size: ${defaultBatchSize}`);
68897
+ mintingResponse = undefined;
68898
+ batchSize = defaultBatchSize;
68899
+ }
68900
+ // get mints to be submitted
68901
+ const pendingMints = await mintingPersistence.getNextBatchForSubmission(batchSize);
68902
+ if (pendingMints.length === 0) {
68903
+ logger.info('no assets to mint');
68904
+ continue;
68905
+ }
68906
+ // chunk assets by every 100 assets. every chunk should all be for the same contract address.
68907
+ const chunkedAssets = pendingMints.sort((a, b) => (a.contract_address > b.contract_address ? 1 : -1)).reduce((acc, row) => {
68908
+ if (acc.length === 0) {
68909
+ return [{ contractAddress: row.contract_address, assets: [row] }];
68910
+ }
68911
+ const lastBatch = acc[acc.length - 1];
68912
+ if (lastBatch.contractAddress === row.contract_address && lastBatch.assets.length < 100) {
68913
+ return [...acc.slice(0, -1), { ...lastBatch, assets: [...lastBatch.assets, row] }];
68914
+ }
68915
+ return [...acc, { contractAddress: row.contract_address, assets: [row] }];
68916
+ }, []);
68917
+ // submit minting request for each contract address in parallel
68918
+ const mintingResults = await Promise.allSettled(chunkedAssets.map(async ({ contractAddress, assets }) => {
68919
+ const mintingRequest = {
68920
+ chainName,
68921
+ contractAddress,
68922
+ createMintRequestRequest: {
68923
+ assets: assets.map((row) => ({
68924
+ reference_id: row.asset_id,
68925
+ owner_address: row.owner_address,
68926
+ metadata: row.metadata,
68927
+ })),
68928
+ },
68929
+ };
68930
+ try {
68931
+ const response = await blockchainDataSDKClient.createMintRequest(mintingRequest);
68932
+ logger.info(`mintingResponse: ${JSON.stringify(response, null, 2)}`);
68933
+ // update minting status to submitted
68934
+ await mintingPersistence.updateMintingStatusToSubmitted(assets.map(({ id }) => id));
68935
+ return response;
68936
+ }
68937
+ catch (e) {
68938
+ logger.error(e);
68939
+ if (e.code === 'CONFLICT_ERROR'
68940
+ && e.details?.id === 'reference_id') {
68941
+ try {
68942
+ // mark the assets as conflicting, so that we don't send them again.
68943
+ await mintingPersistence.markAsConflict(e.details.values, contractAddress);
68944
+ // remove non conflicting assets status so that they can be retried.
68945
+ await mintingPersistence.resetMintingStatus(assets
68946
+ .map(({ id }) => id)
68947
+ .filter((id) => !e.details.values.includes(id)));
68948
+ }
68949
+ catch (e2) {
68950
+ logger.error(e2);
68951
+ }
68952
+ }
68953
+ else {
68954
+ // separate assets into "need to be retied" and "exceeded max number of tries."
68955
+ const { assetsToRetry, assetsExceededMaxNumberOfTries } = assets.reduce((acc, { tried_count = 0, id }) => {
68956
+ if (tried_count < maxNumberOfTries) {
68957
+ acc.assetsToRetry.push(id);
68958
+ }
68959
+ else {
68960
+ acc.assetsExceededMaxNumberOfTries.push(id);
68961
+ }
68962
+ return acc;
68963
+ }, {
68964
+ assetsToRetry: [],
68965
+ assetsExceededMaxNumberOfTries: [],
68966
+ });
68967
+ // remove all assets status so that they can be retried.
68968
+ await mintingPersistence.markForRetry(assetsToRetry);
68969
+ // mark assets that have exceeded the max number of tries as submission_failed
68970
+ await mintingPersistence.updateMintingStatusToSubmissionFailed(assetsExceededMaxNumberOfTries);
68971
+ }
68972
+ return e;
68973
+ }
68974
+ }));
68975
+ mintingResponse = mintingResults
68976
+ .reverse()
68977
+ .find((r) => r.status === 'fulfilled')?.value;
68978
+ }
68979
+ };
68980
+ const processMint = async (mintingPersistence, event, logger = console) => {
68981
+ if (event.event_name !== 'imtbl_zkevm_mint_request_updated') {
68982
+ logger.info(`${event.event_name} is not imtbl_zkevm_mint_request_updated, skip.`);
68983
+ return;
68984
+ }
68985
+ const referenceId = event.data.reference_id;
68986
+ if (!referenceId) {
68987
+ throw new Error('reference_id not found in webhook event');
68988
+ }
68989
+ const contractAddress = event.data.contract_address;
68990
+ if (!contractAddress) {
68991
+ throw new Error('contract_address not found in webhook event');
68992
+ }
68993
+ if (event.data.status === 'failed') {
68994
+ logger.error(`mint failed: ${JSON.stringify(event.data, null, 2)}`);
68995
+ }
68996
+ const mintReq = await mintingPersistence.getMintingRequest(contractAddress, referenceId);
68997
+ if (!mintReq) {
68998
+ logger.info(`minting request not found in the database, ${JSON.stringify(event.data)}`);
68999
+ }
69000
+ const ownerAddress = mintReq?.wallet_address || event.data.owner_address;
69001
+ if (!ownerAddress) {
69002
+ logger.error('owner_address missing');
69003
+ throw new Error('owner_address missing');
69004
+ }
69005
+ await mintingPersistence.syncMintingStatus({
69006
+ tokenId: event.data.token_id,
69007
+ status: event.data.status,
69008
+ assetId: referenceId,
69009
+ contractAddress,
69010
+ ownerAddress,
69011
+ metadataId: event.data.metadata_id,
69012
+ imtblZkevmMintRequestUpdatedId: event.event_id,
69013
+ error: event.data.error ? JSON.stringify(event.data.error) : null,
69014
+ });
69015
+ };
69016
+
69017
+ var minting_backend = /*#__PURE__*/Object.freeze({
69018
+ __proto__: null,
69019
+ mintingPersistencePg: mintingPersistence,
69020
+ processMint: processMint,
69021
+ recordMint: recordMint,
69022
+ submitMintingRequests: submitMintingRequests
69023
+ });
69024
+
68712
69025
  exports.blockchainData = blockchain_data;
68713
69026
  exports.checkout = checkout;
68714
69027
  exports.config = config;
69028
+ exports.mintingBackend = minting_backend;
68715
69029
  exports.orderbook = orderbook;
68716
69030
  exports.passport = passport;
69031
+ exports.webhook = webhook;
68717
69032
  exports.x = x;
package/dist/index.d.ts CHANGED
@@ -7841,7 +7841,7 @@ interface MintUser$1 {
7841
7841
  * @export
7842
7842
  * @interface MintRequest
7843
7843
  */
7844
- interface MintRequest$1 {
7844
+ interface MintRequest$2 {
7845
7845
  /**
7846
7846
  * Signature from authorised minter
7847
7847
  * @type {string}
@@ -10820,7 +10820,7 @@ interface MintsApiMintTokensRequest$1 {
10820
10820
  * @type {Array<MintRequest>}
10821
10821
  * @memberof MintsApiMintTokens
10822
10822
  */
10823
- readonly mintTokensRequestV2: Array<MintRequest$1>;
10823
+ readonly mintTokensRequestV2: Array<MintRequest$2>;
10824
10824
  }
10825
10825
  /**
10826
10826
  * MintsApi - object-oriented interface
@@ -21026,7 +21026,7 @@ type UnsignedTransferRequest = TokenAmount & {
21026
21026
  /**
21027
21027
  * Parameter required to Mint tokens
21028
21028
  */
21029
- type UnsignedMintRequest = Omit<MintRequest$1, 'auth_signature'>;
21029
+ type UnsignedMintRequest = Omit<MintRequest$2, 'auth_signature'>;
21030
21030
  /**
21031
21031
  * Parameter required to create a Transfer
21032
21032
  */
@@ -21184,7 +21184,7 @@ interface MetadataSchemaRequest extends MetadataSchemaRequest$1 {
21184
21184
  }
21185
21185
  interface MintFee extends MintFee$1 {
21186
21186
  }
21187
- interface MintRequest extends MintRequest$1 {
21187
+ interface MintRequest$1 extends MintRequest$2 {
21188
21188
  }
21189
21189
  interface MintTokenDataV2 extends MintTokenDataV2$1 {
21190
21190
  }
@@ -29056,7 +29056,6 @@ declare const x_d_MetadataRefreshesApi: typeof MetadataRefreshesApi;
29056
29056
  type x_d_MetadataSchemaRequest = MetadataSchemaRequest;
29057
29057
  declare const x_d_MetadataSchemaRequestTypeEnum: typeof MetadataSchemaRequestTypeEnum;
29058
29058
  type x_d_MintFee = MintFee;
29059
- type x_d_MintRequest = MintRequest;
29060
29059
  type x_d_MintTokenDataV2 = MintTokenDataV2;
29061
29060
  type x_d_MintTokensResponse = MintTokensResponse;
29062
29061
  type x_d_MintUser = MintUser;
@@ -29199,7 +29198,7 @@ declare namespace x_d {
29199
29198
  x_d_MetadataSchemaRequest as MetadataSchemaRequest,
29200
29199
  x_d_MetadataSchemaRequestTypeEnum as MetadataSchemaRequestTypeEnum,
29201
29200
  x_d_MintFee as MintFee,
29202
- x_d_MintRequest as MintRequest,
29201
+ MintRequest$1 as MintRequest,
29203
29202
  x_d_MintTokenDataV2 as MintTokenDataV2,
29204
29203
  x_d_MintTokensResponse as MintTokensResponse,
29205
29204
  x_d_MintUser as MintUser,
@@ -29263,4 +29262,105 @@ declare namespace x_d {
29263
29262
  };
29264
29263
  }
29265
29264
 
29266
- export { blockchain_data_d as blockchainData, checkout_d as checkout, config_d as config, orderbook_d as orderbook, passport_d as passport, x_d as x };
29265
+ declare const init: (body: string | Record<string, unknown>, env: Environment, handlers: {
29266
+ zkevmMintRequestUpdated: (event: any) => Promise<void>;
29267
+ others?: ((event: any) => Promise<void>) | undefined;
29268
+ }) => Promise<void>;
29269
+
29270
+ declare const webhook_d_init: typeof init;
29271
+ declare namespace webhook_d {
29272
+ export {
29273
+ webhook_d_init as init,
29274
+ };
29275
+ }
29276
+
29277
+ type CreateMintRequest = {
29278
+ contract_address: string;
29279
+ asset_id: string;
29280
+ metadata: any;
29281
+ owner_address: string;
29282
+ };
29283
+ type MintRequest = {
29284
+ id: string;
29285
+ contract_address: string;
29286
+ wallet_address: string;
29287
+ asset_id: string;
29288
+ metadata: any;
29289
+ owner_address: string;
29290
+ tried_count: number;
29291
+ };
29292
+ type SubmittedMintRequest = {
29293
+ tokenId: string | null;
29294
+ status: string;
29295
+ assetId: string;
29296
+ contractAddress: string;
29297
+ ownerAddress: string;
29298
+ metadataId: string;
29299
+ imtblZkevmMintRequestUpdatedId: string;
29300
+ error: any | null;
29301
+ };
29302
+ interface MintingPersistence {
29303
+ recordMint: (request: CreateMintRequest) => Promise<void>;
29304
+ getNextBatchForSubmission: (limit: number) => Promise<MintRequest[]>;
29305
+ updateMintingStatusToSubmitted: (id: string[]) => Promise<void>;
29306
+ updateMintingStatusToSubmissionFailed: (id: string[]) => Promise<void>;
29307
+ syncMintingStatus: (submittedMintRequest: SubmittedMintRequest) => Promise<void>;
29308
+ markAsConflict: (assetIds: string[], contractAddress: string) => Promise<void>;
29309
+ resetMintingStatus: (ids: string[]) => Promise<void>;
29310
+ markForRetry: (ids: string[]) => Promise<void>;
29311
+ getMintingRequest: (contractAddress: string, referenceId: string) => Promise<MintRequest>;
29312
+ }
29313
+
29314
+ declare const mintingPersistence: MintingPersistence;
29315
+
29316
+ interface Logger {
29317
+ info: (message: string) => void;
29318
+ error: (message: any) => void;
29319
+ }
29320
+
29321
+ declare const recordMint: (mintingPersistence: MintingPersistence, mintRequest: CreateMintRequest) => Promise<void>;
29322
+ declare const submitMintingRequests: (mintingPersistence: MintingPersistence, blockchainDataSDKClient: BlockchainData, { defaultBatchSize, chainName, maxNumberOfTries, }: {
29323
+ defaultBatchSize?: number | undefined;
29324
+ chainName?: string | undefined;
29325
+ maxNumberOfTries?: number | undefined;
29326
+ }, logger?: Logger) => Promise<never>;
29327
+ type MintRequestEvent = {
29328
+ event_name: string;
29329
+ chain: string;
29330
+ event_id: string;
29331
+ data: {
29332
+ chain: {
29333
+ id: string;
29334
+ name: string;
29335
+ };
29336
+ contract_address: string;
29337
+ owner_address: string;
29338
+ reference_id: string;
29339
+ metadata_id: string;
29340
+ token_id: string | null;
29341
+ status: string;
29342
+ transaction_hash: string | null;
29343
+ activity_id: string | null;
29344
+ error: {
29345
+ code: string;
29346
+ message: string;
29347
+ } | null;
29348
+ created_at: string;
29349
+ updated_at: string;
29350
+ };
29351
+ };
29352
+ declare const processMint: (mintingPersistence: MintingPersistence, event: MintRequestEvent, logger?: Logger) => Promise<void>;
29353
+
29354
+ declare const minting_backend_d_processMint: typeof processMint;
29355
+ declare const minting_backend_d_recordMint: typeof recordMint;
29356
+ declare const minting_backend_d_submitMintingRequests: typeof submitMintingRequests;
29357
+ declare namespace minting_backend_d {
29358
+ export {
29359
+ mintingPersistence as mintingPersistencePg,
29360
+ minting_backend_d_processMint as processMint,
29361
+ minting_backend_d_recordMint as recordMint,
29362
+ minting_backend_d_submitMintingRequests as submitMintingRequests,
29363
+ };
29364
+ }
29365
+
29366
+ export { blockchain_data_d as blockchainData, checkout_d as checkout, config_d as config, minting_backend_d as mintingBackend, orderbook_d as orderbook, passport_d as passport, webhook_d as webhook, x_d as x };