@imtbl/sdk 0.43.0 → 0.44.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
@@ -10641,7 +10641,7 @@ class MultiRollupApiClients {
10641
10641
  }
10642
10642
 
10643
10643
  // eslint-disable-next-line @typescript-eslint/naming-convention
10644
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.43.0' };
10644
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.1' };
10645
10645
  const createConfig = ({ basePath, headers, }) => {
10646
10646
  if (!basePath.trim()) {
10647
10647
  throw Error('basePath can not be empty');
@@ -10713,7 +10713,7 @@ class APIError extends Error {
10713
10713
 
10714
10714
  /* eslint-disable implicit-arrow-linebreak */
10715
10715
  const defaultHeaders = {
10716
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.43.0',
10716
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.1',
10717
10717
  };
10718
10718
  /**
10719
10719
  * createAPIConfiguration to create a custom Configuration
@@ -11152,7 +11152,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11152
11152
  chainID,
11153
11153
  coreContractAddress,
11154
11154
  registrationContractAddress,
11155
- sdkVersion: 'ts-immutable-sdk-0.43.0',
11155
+ sdkVersion: 'ts-immutable-sdk-0.44.1',
11156
11156
  });
11157
11157
  /**
11158
11158
  * Sets `sdkVersion` at the time of build
@@ -17303,27 +17303,43 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
17303
17303
  const types = { ...typedData.types };
17304
17304
  // @ts-ignore
17305
17305
  delete types.EIP712Domain;
17306
- // eslint-disable-next-line no-underscore-dangle
17307
- const digest = ethers.ethers.utils._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
17308
- const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
17309
- const hash = ethers.ethers.utils.keccak256(completePayload);
17310
- // Sign the digest
17306
+ // Hash the EIP712 payload and generate the complete payload
17307
+ const { _TypedDataEncoder: typedDataEncoder } = ethers.ethers.utils;
17308
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
17309
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
17310
+ const hash = ethers.ethers.utils.keccak256(messageSubDigest);
17311
+ // Sign the sub digest
17312
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
17311
17313
  const hashArray = ethers.ethers.utils.arrayify(hash);
17312
17314
  const ethsigNoType = await signer.signMessage(hashArray);
17313
17315
  const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
17314
- const { signers } = decodeRelayerTypedDataSignature(relayerSignature);
17316
+ // Combine the relayer and user signatures; sort by address to match the imageHash order
17317
+ const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
17318
+ const combinedSigners = [
17319
+ ...relayerSigners,
17320
+ {
17321
+ isDynamic: false,
17322
+ unrecovered: true,
17323
+ weight: SIGNATURE_WEIGHT,
17324
+ signature: signedDigest,
17325
+ address: await signer.getAddress(),
17326
+ },
17327
+ ];
17328
+ const sortedSigners = combinedSigners.sort((a, b) => {
17329
+ const bigA = ethers.BigNumber.from(a.address);
17330
+ const bigB = ethers.BigNumber.from(b.address);
17331
+ if (bigA.lte(bigB)) {
17332
+ return -1;
17333
+ }
17334
+ if (bigA.eq(bigB)) {
17335
+ return 0;
17336
+ }
17337
+ return 1;
17338
+ });
17315
17339
  return core.v1.signature.encodeSignature({
17316
17340
  version: 1,
17317
17341
  threshold: EIP712_SIGNATURE_THRESHOLD,
17318
- signers: [
17319
- ...signers,
17320
- {
17321
- isDynamic: false,
17322
- unrecovered: true,
17323
- weight: SIGNATURE_WEIGHT,
17324
- signature: signedDigest,
17325
- },
17326
- ],
17342
+ signers: sortedSigners,
17327
17343
  });
17328
17344
  };
17329
17345
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
@@ -17908,9 +17924,6 @@ class Passport {
17908
17924
  return this.passportImxProviderFactory.getProvider();
17909
17925
  }
17910
17926
  connectEvm() {
17911
- if (this.config.baseConfig.environment === 'production') {
17912
- throw new Error('EVM is not supported on production network');
17913
- }
17914
17927
  return new ZkEvmProvider({
17915
17928
  passportEventEmitter: this.passportEventEmitter,
17916
17929
  authManager: this.authManager,
@@ -41945,7 +41958,7 @@ const GAS_OVERRIDES = {
41945
41958
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
41946
41959
  };
41947
41960
 
41948
- const SDK_VERSION_MARKER = '0.43.0';
41961
+ const SDK_VERSION_MARKER = '0.44.1';
41949
41962
  // This SDK version is replaced by the `yarn build` command ran on the root level
41950
41963
  const globalPackageVersion = () => SDK_VERSION_MARKER;
41951
41964
 
@@ -45213,7 +45226,7 @@ const sell = async (config, provider, orders) => {
45213
45226
  if (orders.length === 0) {
45214
45227
  throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR);
45215
45228
  }
45216
- const { buyToken, sellToken, makerFees } = orders[0];
45229
+ const { buyToken, sellToken, makerFees, orderExpiry, } = orders[0];
45217
45230
  let decimals = 18;
45218
45231
  if (buyToken.type === ItemType.ERC20) {
45219
45232
  // get this from the allowed list
@@ -45234,6 +45247,7 @@ const sell = async (config, provider, orders) => {
45234
45247
  contractAddress: sellToken.collectionAddress,
45235
45248
  tokenId: sellToken.id,
45236
45249
  },
45250
+ orderExpiry,
45237
45251
  }));
45238
45252
  }
45239
45253
  catch (err) {
@@ -45825,8 +45839,23 @@ class Checkout {
45825
45839
  }
45826
45840
  }
45827
45841
 
45842
+ class BlockExplorerService {
45843
+ /**
45844
+ * getTransationLink returns the link to the transaction on blockscout
45845
+ * @param hash transaction hash
45846
+ * @returns link to the transaction on blockscout
45847
+ */
45848
+ static getTransactionLink(chainId, hash) {
45849
+ const url = BLOCKSCOUT_CHAIN_URL_MAP?.[chainId]?.url;
45850
+ if (!url || !hash)
45851
+ return undefined;
45852
+ return `${url}/tx/${hash}`;
45853
+ }
45854
+ }
45855
+
45828
45856
  var checkout = /*#__PURE__*/Object.freeze({
45829
45857
  __proto__: null,
45858
+ BlockExplorerService: BlockExplorerService,
45830
45859
  get BridgeEventType () { return BridgeEventType; },
45831
45860
  get ChainId () { return ChainId; },
45832
45861
  get ChainName () { return ChainName; },
package/dist/index.d.ts CHANGED
@@ -17202,8 +17202,10 @@ type SellOrder = {
17202
17202
  sellToken: SellToken;
17203
17203
  /** the token info of the price of the item */
17204
17204
  buyToken: BuyToken;
17205
- /** option array of makerFees to be applied to the listing */
17205
+ /** optional array of makerFees to be applied to the listing */
17206
17206
  makerFees?: OrderFee[];
17207
+ /** optional order expiry date. Default order expiry to 2 years from now */
17208
+ orderExpiry?: Date;
17207
17209
  };
17208
17210
  /**
17209
17211
  * Represents the token that the item can be bought with once listed for sale.
@@ -18895,10 +18897,14 @@ type OnRampWidgetParams = {
18895
18897
  type SaleWidgetParams = {
18896
18898
  /** The total price to pay for the items in the sale */
18897
18899
  amount?: string;
18900
+ /** Environment id from Immutable Hub */
18898
18901
  environmentId?: string;
18902
+ /** Contract address of the token accepted for payments */
18899
18903
  fromTokenAddress?: string;
18900
18904
  /** The list of products to be purchased */
18901
18905
  items?: SaleItem[];
18906
+ /** The name of the NFT collection on sale */
18907
+ collectionName?: string;
18902
18908
  /** The wallet provider name to default to if no web3Provider is passed */
18903
18909
  walletProviderName?: WalletProviderName;
18904
18910
  /** The language to use for the sales widget */
@@ -19442,9 +19448,20 @@ type ErrorType = {
19442
19448
  };
19443
19449
  };
19444
19450
 
19451
+ declare class BlockExplorerService {
19452
+ /**
19453
+ * getTransationLink returns the link to the transaction on blockscout
19454
+ * @param hash transaction hash
19455
+ * @returns link to the transaction on blockscout
19456
+ */
19457
+ static getTransactionLink(chainId: ChainId, hash: string): string | undefined;
19458
+ }
19459
+
19445
19460
  type checkout_d_AllowedNetworkConfig = AllowedNetworkConfig;
19446
19461
  type checkout_d_AvailableRoutingOptions = AvailableRoutingOptions;
19447
19462
  type checkout_d_BalanceDelta = BalanceDelta;
19463
+ type checkout_d_BlockExplorerService = BlockExplorerService;
19464
+ declare const checkout_d_BlockExplorerService: typeof BlockExplorerService;
19448
19465
  type checkout_d_BridgeEventType = BridgeEventType;
19449
19466
  declare const checkout_d_BridgeEventType: typeof BridgeEventType;
19450
19467
  type checkout_d_BridgeFailed = BridgeFailed;
@@ -19654,6 +19671,7 @@ declare namespace checkout_d {
19654
19671
  checkout_d_AllowedNetworkConfig as AllowedNetworkConfig,
19655
19672
  checkout_d_AvailableRoutingOptions as AvailableRoutingOptions,
19656
19673
  checkout_d_BalanceDelta as BalanceDelta,
19674
+ checkout_d_BlockExplorerService as BlockExplorerService,
19657
19675
  checkout_d_BridgeEventType as BridgeEventType,
19658
19676
  checkout_d_BridgeFailed as BridgeFailed,
19659
19677
  checkout_d_BridgeFundingStep as BridgeFundingStep,
package/dist/index.js CHANGED
@@ -10619,7 +10619,7 @@ class MultiRollupApiClients {
10619
10619
  }
10620
10620
 
10621
10621
  // eslint-disable-next-line @typescript-eslint/naming-convention
10622
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.43.0' };
10622
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.1' };
10623
10623
  const createConfig = ({ basePath, headers, }) => {
10624
10624
  if (!basePath.trim()) {
10625
10625
  throw Error('basePath can not be empty');
@@ -10691,7 +10691,7 @@ class APIError extends Error {
10691
10691
 
10692
10692
  /* eslint-disable implicit-arrow-linebreak */
10693
10693
  const defaultHeaders = {
10694
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.43.0',
10694
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.1',
10695
10695
  };
10696
10696
  /**
10697
10697
  * createAPIConfiguration to create a custom Configuration
@@ -11130,7 +11130,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11130
11130
  chainID,
11131
11131
  coreContractAddress,
11132
11132
  registrationContractAddress,
11133
- sdkVersion: 'ts-immutable-sdk-0.43.0',
11133
+ sdkVersion: 'ts-immutable-sdk-0.44.1',
11134
11134
  });
11135
11135
  /**
11136
11136
  * Sets `sdkVersion` at the time of build
@@ -17281,27 +17281,43 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
17281
17281
  const types = { ...typedData.types };
17282
17282
  // @ts-ignore
17283
17283
  delete types.EIP712Domain;
17284
- // eslint-disable-next-line no-underscore-dangle
17285
- const digest = ethers.utils._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
17286
- const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
17287
- const hash = ethers.utils.keccak256(completePayload);
17288
- // Sign the digest
17284
+ // Hash the EIP712 payload and generate the complete payload
17285
+ const { _TypedDataEncoder: typedDataEncoder } = ethers.utils;
17286
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
17287
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
17288
+ const hash = ethers.utils.keccak256(messageSubDigest);
17289
+ // Sign the sub digest
17290
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
17289
17291
  const hashArray = ethers.utils.arrayify(hash);
17290
17292
  const ethsigNoType = await signer.signMessage(hashArray);
17291
17293
  const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
17292
- const { signers } = decodeRelayerTypedDataSignature(relayerSignature);
17294
+ // Combine the relayer and user signatures; sort by address to match the imageHash order
17295
+ const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
17296
+ const combinedSigners = [
17297
+ ...relayerSigners,
17298
+ {
17299
+ isDynamic: false,
17300
+ unrecovered: true,
17301
+ weight: SIGNATURE_WEIGHT,
17302
+ signature: signedDigest,
17303
+ address: await signer.getAddress(),
17304
+ },
17305
+ ];
17306
+ const sortedSigners = combinedSigners.sort((a, b) => {
17307
+ const bigA = BigNumber$1.from(a.address);
17308
+ const bigB = BigNumber$1.from(b.address);
17309
+ if (bigA.lte(bigB)) {
17310
+ return -1;
17311
+ }
17312
+ if (bigA.eq(bigB)) {
17313
+ return 0;
17314
+ }
17315
+ return 1;
17316
+ });
17293
17317
  return v1.signature.encodeSignature({
17294
17318
  version: 1,
17295
17319
  threshold: EIP712_SIGNATURE_THRESHOLD,
17296
- signers: [
17297
- ...signers,
17298
- {
17299
- isDynamic: false,
17300
- unrecovered: true,
17301
- weight: SIGNATURE_WEIGHT,
17302
- signature: signedDigest,
17303
- },
17304
- ],
17320
+ signers: sortedSigners,
17305
17321
  });
17306
17322
  };
17307
17323
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
@@ -17886,9 +17902,6 @@ class Passport {
17886
17902
  return this.passportImxProviderFactory.getProvider();
17887
17903
  }
17888
17904
  connectEvm() {
17889
- if (this.config.baseConfig.environment === 'production') {
17890
- throw new Error('EVM is not supported on production network');
17891
- }
17892
17905
  return new ZkEvmProvider({
17893
17906
  passportEventEmitter: this.passportEventEmitter,
17894
17907
  authManager: this.authManager,
@@ -41923,7 +41936,7 @@ const GAS_OVERRIDES = {
41923
41936
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
41924
41937
  };
41925
41938
 
41926
- const SDK_VERSION_MARKER = '0.43.0';
41939
+ const SDK_VERSION_MARKER = '0.44.1';
41927
41940
  // This SDK version is replaced by the `yarn build` command ran on the root level
41928
41941
  const globalPackageVersion = () => SDK_VERSION_MARKER;
41929
41942
 
@@ -45191,7 +45204,7 @@ const sell = async (config, provider, orders) => {
45191
45204
  if (orders.length === 0) {
45192
45205
  throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR);
45193
45206
  }
45194
- const { buyToken, sellToken, makerFees } = orders[0];
45207
+ const { buyToken, sellToken, makerFees, orderExpiry, } = orders[0];
45195
45208
  let decimals = 18;
45196
45209
  if (buyToken.type === ItemType.ERC20) {
45197
45210
  // get this from the allowed list
@@ -45212,6 +45225,7 @@ const sell = async (config, provider, orders) => {
45212
45225
  contractAddress: sellToken.collectionAddress,
45213
45226
  tokenId: sellToken.id,
45214
45227
  },
45228
+ orderExpiry,
45215
45229
  }));
45216
45230
  }
45217
45231
  catch (err) {
@@ -45803,8 +45817,23 @@ class Checkout {
45803
45817
  }
45804
45818
  }
45805
45819
 
45820
+ class BlockExplorerService {
45821
+ /**
45822
+ * getTransationLink returns the link to the transaction on blockscout
45823
+ * @param hash transaction hash
45824
+ * @returns link to the transaction on blockscout
45825
+ */
45826
+ static getTransactionLink(chainId, hash) {
45827
+ const url = BLOCKSCOUT_CHAIN_URL_MAP?.[chainId]?.url;
45828
+ if (!url || !hash)
45829
+ return undefined;
45830
+ return `${url}/tx/${hash}`;
45831
+ }
45832
+ }
45833
+
45806
45834
  var checkout = /*#__PURE__*/Object.freeze({
45807
45835
  __proto__: null,
45836
+ BlockExplorerService: BlockExplorerService,
45808
45837
  get BridgeEventType () { return BridgeEventType; },
45809
45838
  get ChainId () { return ChainId; },
45810
45839
  get ChainName () { return ChainName; },
package/dist/passport.js CHANGED
@@ -8724,7 +8724,7 @@ class MultiRollupApiClients {
8724
8724
  }
8725
8725
 
8726
8726
  // eslint-disable-next-line @typescript-eslint/naming-convention
8727
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.43.0' };
8727
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.44.1' };
8728
8728
  const createConfig = ({ basePath, headers, }) => {
8729
8729
  if (!basePath.trim()) {
8730
8730
  throw Error('basePath can not be empty');
@@ -8792,7 +8792,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
8792
8792
  chainID,
8793
8793
  coreContractAddress,
8794
8794
  registrationContractAddress,
8795
- sdkVersion: 'ts-immutable-sdk-0.43.0',
8795
+ sdkVersion: 'ts-immutable-sdk-0.44.1',
8796
8796
  });
8797
8797
  /**
8798
8798
  * Sets `sdkVersion` at the time of build
@@ -14926,27 +14926,43 @@ const getSignedTypedData = async (typedData, relayerSignature, chainId, walletAd
14926
14926
  const types = { ...typedData.types };
14927
14927
  // @ts-ignore
14928
14928
  delete types.EIP712Domain;
14929
- // eslint-disable-next-line no-underscore-dangle
14930
- const digest = ethers.utils._TypedDataEncoder.hash(typedData.domain, types, typedData.message);
14931
- const completePayload = encodeMessageSubDigest(chainId, walletAddress, digest);
14932
- const hash = ethers.utils.keccak256(completePayload);
14933
- // Sign the digest
14929
+ // Hash the EIP712 payload and generate the complete payload
14930
+ const { _TypedDataEncoder: typedDataEncoder } = ethers.utils;
14931
+ const typedDataHash = typedDataEncoder.hash(typedData.domain, types, typedData.message);
14932
+ const messageSubDigest = encodeMessageSubDigest(chainId, walletAddress, typedDataHash);
14933
+ const hash = ethers.utils.keccak256(messageSubDigest);
14934
+ // Sign the sub digest
14935
+ // https://github.com/immutable/wallet-contracts/blob/7824b5f24b2e0eb2dc465ecb5cd71f3984556b73/src/contracts/modules/commons/ModuleAuth.sol#L155
14934
14936
  const hashArray = ethers.utils.arrayify(hash);
14935
14937
  const ethsigNoType = await signer.signMessage(hashArray);
14936
14938
  const signedDigest = `${ethsigNoType}${ETH_SIGN_FLAG}`;
14937
- const { signers } = decodeRelayerTypedDataSignature(relayerSignature);
14939
+ // Combine the relayer and user signatures; sort by address to match the imageHash order
14940
+ const { signers: relayerSigners } = decodeRelayerTypedDataSignature(relayerSignature);
14941
+ const combinedSigners = [
14942
+ ...relayerSigners,
14943
+ {
14944
+ isDynamic: false,
14945
+ unrecovered: true,
14946
+ weight: SIGNATURE_WEIGHT,
14947
+ signature: signedDigest,
14948
+ address: await signer.getAddress(),
14949
+ },
14950
+ ];
14951
+ const sortedSigners = combinedSigners.sort((a, b) => {
14952
+ const bigA = BigNumber.from(a.address);
14953
+ const bigB = BigNumber.from(b.address);
14954
+ if (bigA.lte(bigB)) {
14955
+ return -1;
14956
+ }
14957
+ if (bigA.eq(bigB)) {
14958
+ return 0;
14959
+ }
14960
+ return 1;
14961
+ });
14938
14962
  return v1.signature.encodeSignature({
14939
14963
  version: 1,
14940
14964
  threshold: EIP712_SIGNATURE_THRESHOLD,
14941
- signers: [
14942
- ...signers,
14943
- {
14944
- isDynamic: false,
14945
- unrecovered: true,
14946
- weight: SIGNATURE_WEIGHT,
14947
- signature: signedDigest,
14948
- },
14949
- ],
14965
+ signers: sortedSigners,
14950
14966
  });
14951
14967
  };
14952
14968
  const getEip155ChainId = (chainId) => `eip155:${chainId}`;
@@ -15531,9 +15547,6 @@ class Passport {
15531
15547
  return this.passportImxProviderFactory.getProvider();
15532
15548
  }
15533
15549
  connectEvm() {
15534
- if (this.config.baseConfig.environment === 'production') {
15535
- throw new Error('EVM is not supported on production network');
15536
- }
15537
15550
  return new ZkEvmProvider({
15538
15551
  passportEventEmitter: this.passportEventEmitter,
15539
15552
  authManager: this.authManager,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.43.0",
4
+ "version": "0.44.1",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",