@imtbl/sdk 0.1.6-alpha → 0.1.7-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/passport.js CHANGED
@@ -1,3 +1,5 @@
1
+ import * as guardian from '@imtbl/guardian';
2
+ export { guardian };
1
3
  import { ImmutableX, Config, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
2
4
  import { UserManager } from 'oidc-client-ts';
3
5
  import { ethers } from 'ethers';
@@ -20,7 +22,7 @@ const production = () => Config.createConfig({
20
22
  chainID: 1,
21
23
  coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
22
24
  registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
23
- sdkVersion: 'ts-immutable-sdk-0.1.6-alpha',
25
+ sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.1',
24
26
  });
25
27
  /**
26
28
  * Set `sdkVersion` on config
@@ -30,7 +32,7 @@ const sandbox = () => Config.createConfig({
30
32
  chainID: 5,
31
33
  coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
32
34
  registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
33
- sdkVersion: 'ts-immutable-sdk-0.1.6-alpha',
35
+ sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.1',
34
36
  });
35
37
  class ImxConfiguration {
36
38
  immutableXConfig;
@@ -519,24 +521,25 @@ class ImmutableXClient {
519
521
  function serializeEthSignature(sig) {
520
522
  // This is because golang appends a recovery param
521
523
  // https://github.com/ethers-io/ethers.js/issues/823
522
- return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64) +
523
- encUtils.padLeft(sig.s.toString(16), 64) +
524
- encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
524
+ return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
525
+ + encUtils.padLeft(sig.s.toString(16), 64)
526
+ + encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
525
527
  }
526
528
  function importRecoveryParam(v) {
529
+ const isValidBigNumber = new BN(v, 16).cmp(new BN(27)) !== -1
530
+ ? new BN(v, 16).sub(new BN(27)).toNumber()
531
+ : new BN(v, 16).toNumber();
527
532
  return v.trim()
528
- ? new BN(v, 16).cmp(new BN(27)) !== -1
529
- ? new BN(v, 16).sub(new BN(27)).toNumber()
530
- : new BN(v, 16).toNumber()
533
+ ? isValidBigNumber
531
534
  : undefined;
532
535
  }
533
536
  // used chained with serializeEthSignature. serializeEthSignature(deserializeSignature(...))
534
537
  function deserializeSignature(sig, size = 64) {
535
- sig = encUtils.removeHexPrefix(sig);
538
+ const removedHexPrefixSig = encUtils.removeHexPrefix(sig);
536
539
  return {
537
- r: new BN(sig.substring(0, size), 'hex'),
538
- s: new BN(sig.substring(size, size * 2), 'hex'),
539
- recoveryParam: importRecoveryParam(sig.substring(size * 2, size * 2 + 2)),
540
+ r: new BN(removedHexPrefixSig.substring(0, size), 'hex'),
541
+ s: new BN(removedHexPrefixSig.substring(size, size * 2), 'hex'),
542
+ recoveryParam: importRecoveryParam(removedHexPrefixSig.substring(size * 2, size * 2 + 2)),
540
543
  };
541
544
  }
542
545
  async function signRaw(payload, signer) {
@@ -567,6 +570,7 @@ function convertToSignableToken(token) {
567
570
  },
568
571
  };
569
572
  case 'ETH':
573
+ default:
570
574
  return {
571
575
  type: 'ETH',
572
576
  data: {
@@ -1261,7 +1265,7 @@ class PassportImxProvider {
1261
1265
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1262
1266
  }
1263
1267
  getAddress() {
1264
- return Promise.resolve(this.starkSigner.getAddress());
1268
+ return Promise.resolve(this.user.etherKey);
1265
1269
  }
1266
1270
  }
1267
1271
 
@@ -1371,6 +1375,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
1371
1375
  }
1372
1376
 
1373
1377
  // TODO: Remove this once the dependency has been added
1378
+ // eslint-disable-next-line import/no-extraneous-dependencies
1374
1379
  class Passport {
1375
1380
  authManager;
1376
1381
  magicAdapter;
@@ -925,7 +925,6 @@ declare class GenericIMXProvider implements IMXProvider {
925
925
 
926
926
  declare class MetaMaskIMXProvider extends GenericIMXProvider {
927
927
  private static imxSigner;
928
- constructor(config: ProviderConfiguration$1, ethSigner: Signer, starkSigner: StarkSigner);
929
928
  static connect(config: ProviderConfiguration$1): Promise<MetaMaskIMXProvider>;
930
929
  static disconnect(): Promise<void>;
931
930
  static signMessage(message: string): Promise<string>;
package/dist/provider.js CHANGED
@@ -10,24 +10,25 @@ import detectEthereumProvider from '@metamask/detect-provider';
10
10
  function serializeEthSignature(sig) {
11
11
  // This is because golang appends a recovery param
12
12
  // https://github.com/ethers-io/ethers.js/issues/823
13
- return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64) +
14
- encUtils.padLeft(sig.s.toString(16), 64) +
15
- encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
13
+ return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
14
+ + encUtils.padLeft(sig.s.toString(16), 64)
15
+ + encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
16
16
  }
17
17
  function importRecoveryParam(v) {
18
+ const isValidBigNumber = new BN(v, 16).cmp(new BN(27)) !== -1
19
+ ? new BN(v, 16).sub(new BN(27)).toNumber()
20
+ : new BN(v, 16).toNumber();
18
21
  return v.trim()
19
- ? new BN(v, 16).cmp(new BN(27)) !== -1
20
- ? new BN(v, 16).sub(new BN(27)).toNumber()
21
- : new BN(v, 16).toNumber()
22
+ ? isValidBigNumber
22
23
  : undefined;
23
24
  }
24
25
  // used chained with serializeEthSignature. serializeEthSignature(deserializeSignature(...))
25
26
  function deserializeSignature(sig, size = 64) {
26
- sig = encUtils.removeHexPrefix(sig);
27
+ const removedHexPrefixSig = encUtils.removeHexPrefix(sig);
27
28
  return {
28
- r: new BN(sig.substring(0, size), 'hex'),
29
- s: new BN(sig.substring(size, size * 2), 'hex'),
30
- recoveryParam: importRecoveryParam(sig.substring(size * 2, size * 2 + 2)),
29
+ r: new BN(removedHexPrefixSig.substring(0, size), 'hex'),
30
+ s: new BN(removedHexPrefixSig.substring(size, size * 2), 'hex'),
31
+ recoveryParam: importRecoveryParam(removedHexPrefixSig.substring(size * 2, size * 2 + 2)),
31
32
  };
32
33
  }
33
34
  async function signRaw(payload, signer) {
@@ -67,6 +68,7 @@ function convertToSignableToken(token) {
67
68
  },
68
69
  };
69
70
  case 'ETH':
71
+ default:
70
72
  return {
71
73
  type: 'ETH',
72
74
  data: {
@@ -87,8 +89,9 @@ function isChainValid(chainID, config) {
87
89
  }
88
90
  async function validateChain(signer, config) {
89
91
  const chainID = await signer.getChainId();
90
- if (!isChainValid(chainID, config))
92
+ if (!isChainValid(chainID, config)) {
91
93
  throw new Error('The wallet used for this operation is not connected to the correct network.');
94
+ }
92
95
  }
93
96
 
94
97
  async function transfer({ signers: { ethSigner, starkSigner }, request, config, }) {
@@ -135,17 +138,15 @@ async function batchTransfer({ signers: { ethSigner, starkSigner }, request, con
135
138
  await validateChain(ethSigner, config.immutableXConfig);
136
139
  const ethAddress = await ethSigner.getAddress();
137
140
  const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
138
- const signableRequests = request.map((nftTransfer) => {
139
- return {
140
- amount: '1',
141
- token: convertToSignableToken({
142
- type: 'ERC721',
143
- tokenId: nftTransfer.tokenId,
144
- tokenAddress: nftTransfer.tokenAddress,
145
- }),
146
- receiver: nftTransfer.receiver,
147
- };
148
- });
141
+ const signableRequests = request.map((nftTransfer) => ({
142
+ amount: '1',
143
+ token: convertToSignableToken({
144
+ type: 'ERC721',
145
+ tokenId: nftTransfer.tokenId,
146
+ tokenAddress: nftTransfer.tokenAddress,
147
+ }),
148
+ receiver: nftTransfer.receiver,
149
+ }));
149
150
  const signableResult = await transfersApi.getSignableTransfer({
150
151
  getSignableTransferRequestV2: {
151
152
  sender_ether_key: ethAddress,
@@ -159,6 +160,8 @@ async function batchTransfer({ signers: { ethSigner, starkSigner }, request, con
159
160
  const ethSignature = await signRaw(signableMessage, ethSigner);
160
161
  const requests = [];
161
162
  for (const resp of signableResult.data.signable_responses) {
163
+ // TODO: remove once fixed
164
+ // eslint-disable-next-line no-await-in-loop
162
165
  const starkSignature = await starkSigner.signMessage(resp.payload_hash);
163
166
  const req = {
164
167
  sender_vault_id: resp.sender_vault_id,
@@ -386,9 +389,7 @@ async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token,
386
389
  config,
387
390
  });
388
391
  }
389
- else {
390
- return executeWithdrawERC20(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
391
- }
392
+ return executeWithdrawERC20(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
392
393
  }
393
394
 
394
395
  async function executeWithdrawMintableERC721(ethSigner, assetType, starkPublicKey, mintingBlob, config) {
@@ -405,7 +406,7 @@ async function executeRegisterAndWithdrawMintableERC721(ethSigner, assetType, st
405
406
  return ethSigner.sendTransaction(populatedTransaction);
406
407
  }
407
408
  function getMintingBlob(token) {
408
- const id = token.data.id;
409
+ const { id } = token.data;
409
410
  const blueprint = token.data.blueprint || '';
410
411
  return encUtils.sanitizeHex(encUtils.utf8ToHex(`{${id}}:{${blueprint}}`));
411
412
  }
@@ -421,9 +422,7 @@ async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token
421
422
  if (!isRegistered) {
422
423
  return executeRegisterAndWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
423
424
  }
424
- else {
425
- return executeWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
426
- }
425
+ return executeWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
427
426
  }
428
427
  async function executeRegisterAndWithdrawERC721(ethSigner, assetType, starkPublicKey, tokenId, config) {
429
428
  const etherKey = await ethSigner.getAddress();
@@ -448,14 +447,12 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
448
447
  if (!isRegistered) {
449
448
  return executeRegisterAndWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
450
449
  }
451
- else {
452
- return executeWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
453
- }
450
+ return executeWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
454
451
  }
455
452
  async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
456
453
  await validateChain(ethSigner, config.immutableXConfig);
457
- const tokenAddress = token.tokenAddress;
458
- const tokenId = token.tokenId;
454
+ const { tokenAddress } = token;
455
+ const { tokenId } = token;
459
456
  const imxConfig = config.immutableXConfig;
460
457
  const mintsApi = new MintsApi(imxConfig.apiConfiguration);
461
458
  return await mintsApi
@@ -467,7 +464,7 @@ async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token
467
464
  type: 'ERC721',
468
465
  data: {
469
466
  id: tokenId,
470
- tokenAddress: tokenAddress,
467
+ tokenAddress,
471
468
  blueprint: mintableToken.data.blueprint,
472
469
  },
473
470
  }, config))
@@ -501,9 +498,7 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
501
498
  if (!isRegistered) {
502
499
  return executeRegisterAndWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
503
500
  }
504
- else {
505
- return executeWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
506
- }
501
+ return executeWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
507
502
  }
508
503
 
509
504
  async function prepareWithdrawal({ signers, withdrawal, config, }) {
@@ -513,7 +508,11 @@ async function prepareWithdrawal({ signers, withdrawal, config, }) {
513
508
  ...withdrawal,
514
509
  });
515
510
  }
511
+ // TODO: remove once fixed
512
+ // eslint-disable-next-line consistent-return
516
513
  async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, token, config, }) {
514
+ // TODO: please add a reasonable default here
515
+ // eslint-disable-next-line default-case
517
516
  switch (token.type) {
518
517
  case 'ETH':
519
518
  return completeEthWithdrawalAction({ ethSigner, starkPublicKey, config });
@@ -571,6 +570,18 @@ async function createTrade({ signers: { ethSigner, starkSigner }, request, confi
571
570
  return createTradeResponse.data;
572
571
  }
573
572
 
573
+ async function executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config, usersApi) {
574
+ const etherKey = await ethSigner.getAddress();
575
+ const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
576
+ const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
577
+ const populatedTransaction = await coreContract.populateTransaction.registerAndDepositEth(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId);
578
+ return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
579
+ }
580
+ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config) {
581
+ const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
582
+ const populatedTransaction = await coreContract.populateTransaction['deposit(uint256,uint256,uint256)'](starkPublicKey, assetType, vaultId);
583
+ return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
584
+ }
574
585
  async function depositEth({ signers: { ethSigner }, deposit, config, }) {
575
586
  await validateChain(ethSigner, config.immutableXConfig);
576
587
  const user = await ethSigner.getAddress();
@@ -608,23 +619,21 @@ async function depositEth({ signers: { ethSigner }, deposit, config, }) {
608
619
  if (!isRegistered) {
609
620
  return executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig, usersApi);
610
621
  }
611
- else {
612
- return executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig);
613
- }
622
+ return executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig);
614
623
  }
615
- async function executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config, usersApi) {
624
+
625
+ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config, usersApi) {
616
626
  const etherKey = await ethSigner.getAddress();
617
- const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
627
+ const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
618
628
  const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
619
- const populatedTransaction = await coreContract.populateTransaction.registerAndDepositEth(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId);
620
- return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
629
+ const populatedTransaction = await coreContract.populateTransaction.registerAndDepositERC20(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId, quantizedAmount);
630
+ return ethSigner.sendTransaction(populatedTransaction);
621
631
  }
622
- async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config) {
623
- const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
624
- const populatedTransaction = await coreContract.populateTransaction['deposit(uint256,uint256,uint256)'](starkPublicKey, assetType, vaultId);
625
- return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
632
+ async function executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config) {
633
+ const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
634
+ const populatedTransaction = await coreContract.populateTransaction.depositERC20(starkPublicKey, assetType, vaultId, quantizedAmount);
635
+ return ethSigner.sendTransaction(populatedTransaction);
626
636
  }
627
-
628
637
  async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
629
638
  await validateChain(ethSigner, config.immutableXConfig);
630
639
  const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
@@ -635,6 +644,8 @@ async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
635
644
  const usersApi = new UsersApi(apiConfiguration);
636
645
  // Get decimals for this specific ERC20
637
646
  const token = await tokensApi.getToken({ address: deposit.tokenAddress });
647
+ // TODO: remove once fixed
648
+ // eslint-disable-next-line radix
638
649
  const decimals = parseInt(token.data.decimals);
639
650
  const data = {
640
651
  decimals,
@@ -676,23 +687,14 @@ async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
676
687
  if (!isRegistered) {
677
688
  return executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration, usersApi);
678
689
  }
679
- else {
680
- return executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration);
681
- }
690
+ return executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration);
682
691
  }
683
- async function executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config) {
684
- const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
685
- const populatedTransaction = await coreContract.populateTransaction.depositERC20(starkPublicKey, assetType, vaultId, quantizedAmount);
686
- return ethSigner.sendTransaction(populatedTransaction);
687
- }
688
- async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config, usersApi) {
689
- const etherKey = await ethSigner.getAddress();
690
- const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
691
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
692
- const populatedTransaction = await coreContract.populateTransaction.registerAndDepositERC20(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId, quantizedAmount);
692
+
693
+ async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
694
+ const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
695
+ const populatedTransaction = await coreContract.populateTransaction.depositNft(starkPublicKey, assetType, vaultId, tokenId);
693
696
  return ethSigner.sendTransaction(populatedTransaction);
694
697
  }
695
-
696
698
  async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
697
699
  await validateChain(ethSigner, config.immutableXConfig);
698
700
  const user = await ethSigner.getAddress();
@@ -743,18 +745,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
743
745
  if (!isRegistered) {
744
746
  const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
745
747
  const coreContract = Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
746
- // Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
748
+ // Note: proxy registration contract registerAndDepositNft method is not used as
749
+ // it currently fails erc721 transfer ownership check
747
750
  await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
748
751
  }
749
752
  return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
750
753
  }
751
- async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
752
- const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
753
- const populatedTransaction = await coreContract.populateTransaction.depositNft(starkPublicKey, assetType, vaultId, tokenId);
754
- return ethSigner.sendTransaction(populatedTransaction);
755
- }
756
754
 
755
+ // TODO: remove once fixed deposit variable shadowing
756
+ // eslint-disable-next-line consistent-return, @typescript-eslint/no-shadow
757
757
  async function deposit({ signers, deposit, config }) {
758
+ // TODO: please add a reasonable default here
759
+ // eslint-disable-next-line default-case
758
760
  switch (deposit.type) {
759
761
  case 'ETH':
760
762
  return depositEth({ signers, deposit, config });
@@ -892,7 +894,10 @@ class GenericIMXProvider {
892
894
  }
893
895
 
894
896
  const WALLET_ACTION = {
897
+ // TODO: remove once fixed - consider using an enum
898
+ // eslint-disable-next-line @typescript-eslint/naming-convention
895
899
  SWITCH_CHAIN: 'wallet_switchEthereumChain',
900
+ // eslint-disable-next-line @typescript-eslint/naming-convention
896
901
  CONNECT: 'eth_requestAccounts',
897
902
  };
898
903
  function isRequestableProvider(provider) {
@@ -909,6 +914,8 @@ async function connectProvider(provider, chainID) {
909
914
  }
910
915
 
911
916
  const ERRORS = {
917
+ // TODO: remove once fixed - consider using something in line with the naming convention
918
+ // eslint-disable-next-line @typescript-eslint/naming-convention
912
919
  PROVIDER_NOT_FOUND: 'The Metamask provider was not found',
913
920
  };
914
921
  async function connect$1({ chainID, }) {
@@ -1083,9 +1090,6 @@ const withProviderError = async (fn, customError) => {
1083
1090
 
1084
1091
  class MetaMaskIMXProvider extends GenericIMXProvider {
1085
1092
  static imxSigner;
1086
- constructor(config, ethSigner, starkSigner) {
1087
- super(config, ethSigner, starkSigner);
1088
- }
1089
1093
  static async connect(config) {
1090
1094
  return await withProviderError(async () => {
1091
1095
  const metaMaskProvider = await connect$1({
@@ -1107,9 +1111,7 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
1107
1111
  if (!this.imxSigner) {
1108
1112
  throw new ProviderError('Attempted to sign a message with the MetaMask IMX provider without an established connection', ProviderErrorType.PROVIDER_CONNECTION_ERROR);
1109
1113
  }
1110
- return withProviderError(async () => {
1111
- return await this.imxSigner.signMessage(message);
1112
- }, { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
1114
+ return withProviderError(async () => await this.imxSigner.signMessage(message), { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
1113
1115
  }
1114
1116
  }
1115
1117
 
@@ -1122,6 +1124,8 @@ class ProviderConfiguration {
1122
1124
  this.immutableXConfig = overrides.immutableXConfig;
1123
1125
  }
1124
1126
  else {
1127
+ // TODO: remove once a sensible default is chosen
1128
+ // eslint-disable-next-line default-case
1125
1129
  switch (baseConfig.environment) {
1126
1130
  case Environment.SANDBOX: {
1127
1131
  this.immutableXConfig = Config.SANDBOX;
package/package.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.1.6-alpha",
4
+ "version": "0.1.7-alpha.1",
5
5
  "author": "Immutable",
6
6
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
7
7
  "dependencies": {
8
+ "@ethersproject/abstract-signer": "^5.7.0",
8
9
  "@ethersproject/providers": "^5.7.2",
10
+ "@ethersproject/wallet": "^5.7.0",
9
11
  "@imtbl/core-sdk": "^1.1.1-alpha.1",
10
12
  "@magic-ext/oidc": "^1.0.1",
11
13
  "@metamask/detect-provider": "^2.0.0",
14
+ "@opensea/seaport-js": "^1.3.0",
12
15
  "axios": "^1.3.5",
16
+ "bn.js": "^5.2.1",
17
+ "enc-utils": "^3.0.0",
13
18
  "ethers": "^5.7.2",
14
19
  "magic-sdk": "^13.3.1",
15
20
  "oidc-client-ts": "^2.2.1"
@@ -18,7 +23,9 @@
18
23
  "@imtbl/checkout-sdk": "0.0.0",
19
24
  "@imtbl/checkout-widgets": "0.0.0",
20
25
  "@imtbl/config": "0.0.0",
26
+ "@imtbl/cryptofiat": "0.0.0",
21
27
  "@imtbl/immutablex-client": "0.0.0",
28
+ "@imtbl/orderbook": "0.0.0",
22
29
  "@imtbl/passport": "0.0.0",
23
30
  "@imtbl/provider": "0.0.0",
24
31
  "@rollup/plugin-commonjs": "^24.0.1",
@@ -28,7 +35,8 @@
28
35
  "@rollup/plugin-typescript": "^11.0.0",
29
36
  "@yarnpkg/cli": "3.5.0",
30
37
  "@yarnpkg/core": "3.5.0",
31
- "eslint": "^8.37.0",
38
+ "eslint": "^8.40.0",
39
+ "glob": "^10.2.3",
32
40
  "rollup": "^3.17.2",
33
41
  "rollup-plugin-dts": "^5.3.0",
34
42
  "semver": "^7.4.0",
@@ -56,6 +64,10 @@
56
64
  "types": "./dist/passport.d.ts",
57
65
  "import": "./dist/passport.js"
58
66
  },
67
+ "./orderbook": {
68
+ "types": "./dist/orderbook.d.ts",
69
+ "import": "./dist/orderbook.js"
70
+ },
59
71
  "./provider": {
60
72
  "types": "./dist/provider.d.ts",
61
73
  "import": "./dist/provider.js"
@@ -84,6 +96,7 @@
84
96
  "scripts": {
85
97
  "build": "yarn packageList && yarn updateDependencies && yarn regenModules && rm -rf dist && NODE_ENV=production rollup --config rollup.config.js && rm -rf dist/types",
86
98
  "build:only": "rm -rf dist && NODE_ENV=production rollup --config rollup.config.js && rm -rf dist/types",
99
+ "copyBrowserBundles": "node scripts/copyBrowserBundles.js",
87
100
  "generateIndex": "node scripts/generateIndex.js",
88
101
  "lint": "eslint ./src --ext .ts,.jsx,.tsx --max-warnings=0",
89
102
  "packageList": "./scripts/generate-package-list.sh",