@imtbl/sdk 0.29.0-alpha.1 → 0.30.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/dist/passport.js CHANGED
@@ -1924,14 +1924,18 @@ const PassportApiAxiosParamCreator = function (configuration) {
1924
1924
  /**
1925
1925
  * Create a counterfactual address for a user based on their Ethereum address
1926
1926
  * @summary Create a counterfactual address
1927
+ * @param {string} chainName
1927
1928
  * @param {CreateCounterfactualAddressRequest} createCounterfactualAddressRequest
1928
1929
  * @param {*} [options] Override http request option.
1929
1930
  * @throws {RequiredError}
1930
1931
  */
1931
- createCounterfactualAddress: async (createCounterfactualAddressRequest, options = {}) => {
1932
+ createCounterfactualAddress: async (chainName, createCounterfactualAddressRequest, options = {}) => {
1933
+ // verify required parameter 'chainName' is not null or undefined
1934
+ assertParamExists$1('createCounterfactualAddress', 'chainName', chainName);
1932
1935
  // verify required parameter 'createCounterfactualAddressRequest' is not null or undefined
1933
1936
  assertParamExists$1('createCounterfactualAddress', 'createCounterfactualAddressRequest', createCounterfactualAddressRequest);
1934
- const localVarPath = `/passport-mr/v1/counterfactual-address`;
1937
+ const localVarPath = `/v1/chains/{chain_name}/passport/counterfactual-address`
1938
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
1935
1939
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
1936
1940
  const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL$1);
1937
1941
  let baseOptions;
@@ -1954,16 +1958,85 @@ const PassportApiAxiosParamCreator = function (configuration) {
1954
1958
  options: localVarRequestOptions,
1955
1959
  };
1956
1960
  },
1961
+ /**
1962
+ * Create a counterfactual address for a user based on their Ethereum address
1963
+ * @summary Create a counterfactual address
1964
+ * @param {CreateCounterfactualAddressRequestDeprecated} createCounterfactualAddressRequestDeprecated
1965
+ * @param {*} [options] Override http request option.
1966
+ * @throws {RequiredError}
1967
+ */
1968
+ createCounterfactualAddressDeprecated: async (createCounterfactualAddressRequestDeprecated, options = {}) => {
1969
+ // verify required parameter 'createCounterfactualAddressRequestDeprecated' is not null or undefined
1970
+ assertParamExists$1('createCounterfactualAddressDeprecated', 'createCounterfactualAddressRequestDeprecated', createCounterfactualAddressRequestDeprecated);
1971
+ const localVarPath = `/passport-mr/v1/counterfactual-address`;
1972
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
1973
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL$1);
1974
+ let baseOptions;
1975
+ if (configuration) {
1976
+ baseOptions = configuration.baseOptions;
1977
+ }
1978
+ const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
1979
+ const localVarHeaderParameter = {};
1980
+ const localVarQueryParameter = {};
1981
+ // authentication BearerAuth required
1982
+ // http bearer authentication required
1983
+ await setBearerAuthToObject$1(localVarHeaderParameter, configuration);
1984
+ localVarHeaderParameter['Content-Type'] = 'application/json';
1985
+ setSearchParams$1(localVarUrlObj, localVarQueryParameter);
1986
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
1987
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
1988
+ localVarRequestOptions.data = serializeDataIfNeeded$1(createCounterfactualAddressRequestDeprecated, localVarRequestOptions, configuration);
1989
+ return {
1990
+ url: toPathString$1(localVarUrlObj),
1991
+ options: localVarRequestOptions,
1992
+ };
1993
+ },
1957
1994
  /**
1958
1995
  * Get all the Ethereum linked addresses for a user based on its userId
1959
1996
  * @summary Get Ethereum linked addresses for a user
1960
1997
  * @param {string} userId The user\'s userId
1998
+ * @param {string} chainName
1961
1999
  * @param {*} [options] Override http request option.
1962
2000
  * @throws {RequiredError}
1963
2001
  */
1964
- getLinkedAddresses: async (userId, options = {}) => {
2002
+ getLinkedAddresses: async (userId, chainName, options = {}) => {
1965
2003
  // verify required parameter 'userId' is not null or undefined
1966
2004
  assertParamExists$1('getLinkedAddresses', 'userId', userId);
2005
+ // verify required parameter 'chainName' is not null or undefined
2006
+ assertParamExists$1('getLinkedAddresses', 'chainName', chainName);
2007
+ const localVarPath = `/v1/chains/{chain_name}/passport/users/{user_id}/linked-addresses`
2008
+ .replace(`{${"user_id"}}`, encodeURIComponent(String(userId)))
2009
+ .replace(`{${"chain_name"}}`, encodeURIComponent(String(chainName)));
2010
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
2011
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL$1);
2012
+ let baseOptions;
2013
+ if (configuration) {
2014
+ baseOptions = configuration.baseOptions;
2015
+ }
2016
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options };
2017
+ const localVarHeaderParameter = {};
2018
+ const localVarQueryParameter = {};
2019
+ // authentication BearerAuth required
2020
+ // http bearer authentication required
2021
+ await setBearerAuthToObject$1(localVarHeaderParameter, configuration);
2022
+ setSearchParams$1(localVarUrlObj, localVarQueryParameter);
2023
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
2024
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
2025
+ return {
2026
+ url: toPathString$1(localVarUrlObj),
2027
+ options: localVarRequestOptions,
2028
+ };
2029
+ },
2030
+ /**
2031
+ * Get all the Ethereum linked addresses for a user based on its userId
2032
+ * @summary Get Ethereum linked addresses for a user
2033
+ * @param {string} userId The user\'s userId
2034
+ * @param {*} [options] Override http request option.
2035
+ * @throws {RequiredError}
2036
+ */
2037
+ getLinkedAddressesDeprecated: async (userId, options = {}) => {
2038
+ // verify required parameter 'userId' is not null or undefined
2039
+ assertParamExists$1('getLinkedAddressesDeprecated', 'userId', userId);
1967
2040
  const localVarPath = `/passport-mr/v1/users/{userId}/linked-addresses`
1968
2041
  .replace(`{${"userId"}}`, encodeURIComponent(String(userId)));
1969
2042
  // use dummy base URL string because the URL constructor only accepts absolute URLs.
@@ -1998,12 +2071,36 @@ const PassportApiFp = function (configuration) {
1998
2071
  /**
1999
2072
  * Create a counterfactual address for a user based on their Ethereum address
2000
2073
  * @summary Create a counterfactual address
2074
+ * @param {string} chainName
2001
2075
  * @param {CreateCounterfactualAddressRequest} createCounterfactualAddressRequest
2002
2076
  * @param {*} [options] Override http request option.
2003
2077
  * @throws {RequiredError}
2004
2078
  */
2005
- async createCounterfactualAddress(createCounterfactualAddressRequest, options) {
2006
- const localVarAxiosArgs = await localVarAxiosParamCreator.createCounterfactualAddress(createCounterfactualAddressRequest, options);
2079
+ async createCounterfactualAddress(chainName, createCounterfactualAddressRequest, options) {
2080
+ const localVarAxiosArgs = await localVarAxiosParamCreator.createCounterfactualAddress(chainName, createCounterfactualAddressRequest, options);
2081
+ return createRequestFunction$1(localVarAxiosArgs, globalAxios$1, BASE_PATH$1, configuration);
2082
+ },
2083
+ /**
2084
+ * Create a counterfactual address for a user based on their Ethereum address
2085
+ * @summary Create a counterfactual address
2086
+ * @param {CreateCounterfactualAddressRequestDeprecated} createCounterfactualAddressRequestDeprecated
2087
+ * @param {*} [options] Override http request option.
2088
+ * @throws {RequiredError}
2089
+ */
2090
+ async createCounterfactualAddressDeprecated(createCounterfactualAddressRequestDeprecated, options) {
2091
+ const localVarAxiosArgs = await localVarAxiosParamCreator.createCounterfactualAddressDeprecated(createCounterfactualAddressRequestDeprecated, options);
2092
+ return createRequestFunction$1(localVarAxiosArgs, globalAxios$1, BASE_PATH$1, configuration);
2093
+ },
2094
+ /**
2095
+ * Get all the Ethereum linked addresses for a user based on its userId
2096
+ * @summary Get Ethereum linked addresses for a user
2097
+ * @param {string} userId The user\'s userId
2098
+ * @param {string} chainName
2099
+ * @param {*} [options] Override http request option.
2100
+ * @throws {RequiredError}
2101
+ */
2102
+ async getLinkedAddresses(userId, chainName, options) {
2103
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getLinkedAddresses(userId, chainName, options);
2007
2104
  return createRequestFunction$1(localVarAxiosArgs, globalAxios$1, BASE_PATH$1, configuration);
2008
2105
  },
2009
2106
  /**
@@ -2013,8 +2110,8 @@ const PassportApiFp = function (configuration) {
2013
2110
  * @param {*} [options] Override http request option.
2014
2111
  * @throws {RequiredError}
2015
2112
  */
2016
- async getLinkedAddresses(userId, options) {
2017
- const localVarAxiosArgs = await localVarAxiosParamCreator.getLinkedAddresses(userId, options);
2113
+ async getLinkedAddressesDeprecated(userId, options) {
2114
+ const localVarAxiosArgs = await localVarAxiosParamCreator.getLinkedAddressesDeprecated(userId, options);
2018
2115
  return createRequestFunction$1(localVarAxiosArgs, globalAxios$1, BASE_PATH$1, configuration);
2019
2116
  },
2020
2117
  };
@@ -2035,7 +2132,18 @@ class PassportApi extends BaseAPI$1 {
2035
2132
  * @memberof PassportApi
2036
2133
  */
2037
2134
  createCounterfactualAddress(requestParameters, options) {
2038
- return PassportApiFp(this.configuration).createCounterfactualAddress(requestParameters.createCounterfactualAddressRequest, options).then((request) => request(this.axios, this.basePath));
2135
+ return PassportApiFp(this.configuration).createCounterfactualAddress(requestParameters.chainName, requestParameters.createCounterfactualAddressRequest, options).then((request) => request(this.axios, this.basePath));
2136
+ }
2137
+ /**
2138
+ * Create a counterfactual address for a user based on their Ethereum address
2139
+ * @summary Create a counterfactual address
2140
+ * @param {PassportApiCreateCounterfactualAddressDeprecatedRequest} requestParameters Request parameters.
2141
+ * @param {*} [options] Override http request option.
2142
+ * @throws {RequiredError}
2143
+ * @memberof PassportApi
2144
+ */
2145
+ createCounterfactualAddressDeprecated(requestParameters, options) {
2146
+ return PassportApiFp(this.configuration).createCounterfactualAddressDeprecated(requestParameters.createCounterfactualAddressRequestDeprecated, options).then((request) => request(this.axios, this.basePath));
2039
2147
  }
2040
2148
  /**
2041
2149
  * Get all the Ethereum linked addresses for a user based on its userId
@@ -2046,7 +2154,18 @@ class PassportApi extends BaseAPI$1 {
2046
2154
  * @memberof PassportApi
2047
2155
  */
2048
2156
  getLinkedAddresses(requestParameters, options) {
2049
- return PassportApiFp(this.configuration).getLinkedAddresses(requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
2157
+ return PassportApiFp(this.configuration).getLinkedAddresses(requestParameters.userId, requestParameters.chainName, options).then((request) => request(this.axios, this.basePath));
2158
+ }
2159
+ /**
2160
+ * Get all the Ethereum linked addresses for a user based on its userId
2161
+ * @summary Get Ethereum linked addresses for a user
2162
+ * @param {PassportApiGetLinkedAddressesDeprecatedRequest} requestParameters Request parameters.
2163
+ * @param {*} [options] Override http request option.
2164
+ * @throws {RequiredError}
2165
+ * @memberof PassportApi
2166
+ */
2167
+ getLinkedAddressesDeprecated(requestParameters, options) {
2168
+ return PassportApiFp(this.configuration).getLinkedAddressesDeprecated(requestParameters.userId, options).then((request) => request(this.axios, this.basePath));
2050
2169
  }
2051
2170
  }
2052
2171
 
@@ -2072,7 +2191,7 @@ class MultiRollupApiClients {
2072
2191
  }
2073
2192
 
2074
2193
  // eslint-disable-next-line @typescript-eslint/naming-convention
2075
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.29.0-alpha.1' };
2194
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.30.0' };
2076
2195
  const createConfig = ({ basePath, headers, }) => {
2077
2196
  if (!basePath.trim()) {
2078
2197
  throw Error('basePath can not be empty');
@@ -2128,7 +2247,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2128
2247
  chainID,
2129
2248
  coreContractAddress,
2130
2249
  registrationContractAddress,
2131
- sdkVersion: 'ts-immutable-sdk-0.29.0-alpha.1',
2250
+ sdkVersion: 'ts-immutable-sdk-0.30.0',
2132
2251
  });
2133
2252
  /**
2134
2253
  * Sets `sdkVersion` at the time of build
@@ -6626,6 +6745,41 @@ const withPassportError = async (fn, customErrorType) => {
6626
6745
  }
6627
6746
  };
6628
6747
 
6748
+ /**
6749
+ * Enum representing different chain IDs.
6750
+ * @enum {number}
6751
+ * @property {number} IMTBL_ZKEVM_MAINNET - The chain ID for IMTBL ZKEVM Mainnet.
6752
+ * @property {number} IMTBL_ZKEVM_TESTNET - The chain ID for IMTBL ZKEVM Testnet.
6753
+ * @property {number} IMTBL_ZKEVM_DEVNET - The chain ID for IMTBL ZKEVM Devnet.
6754
+ * @property {number} ETHEREUM - The chain ID for Ethereum.
6755
+ * @property {number} SEPOLIA - The chain ID for Sepolia.
6756
+ */
6757
+ var ChainId;
6758
+ (function (ChainId) {
6759
+ ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
6760
+ ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13472] = "IMTBL_ZKEVM_TESTNET";
6761
+ ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13433] = "IMTBL_ZKEVM_DEVNET";
6762
+ ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
6763
+ ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
6764
+ })(ChainId || (ChainId = {}));
6765
+ /**
6766
+ * Enum representing different chain names.
6767
+ * @enum {number}
6768
+ * @property {number} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
6769
+ * @property {number} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
6770
+ * @property {number} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
6771
+ * @property {number} ETHEREUM - The chain name for Ethereum.
6772
+ * @property {number} SEPOLIA - The chain name for Sepolia.
6773
+ */
6774
+ var ChainName;
6775
+ (function (ChainName) {
6776
+ ChainName["ETHEREUM"] = "Ethereum";
6777
+ ChainName["SEPOLIA"] = "Sepolia";
6778
+ ChainName["IMTBL_ZKEVM_TESTNET"] = "Immutable zkEVM Test";
6779
+ ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
6780
+ ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
6781
+ })(ChainName || (ChainName = {}));
6782
+
6629
6783
  const keyCrendentials = 'passport_credentials';
6630
6784
  const KEY_PKCE_STATE = 'pkce_state';
6631
6785
  const KEY_PKCE_VERIFIER = 'pkce_verifier';
@@ -8391,18 +8545,47 @@ class RelayerClient {
8391
8545
  }
8392
8546
  }
8393
8547
 
8548
+ const CHAIN_NAME_MAP = new Map([
8549
+ [
8550
+ ChainId.ETHEREUM,
8551
+ ChainName.ETHEREUM,
8552
+ ],
8553
+ [
8554
+ ChainId.SEPOLIA,
8555
+ ChainName.SEPOLIA,
8556
+ ],
8557
+ [
8558
+ ChainId.IMTBL_ZKEVM_MAINNET,
8559
+ ChainName.IMTBL_ZKEVM_MAINNET,
8560
+ ],
8561
+ [
8562
+ ChainId.IMTBL_ZKEVM_TESTNET,
8563
+ ChainName.IMTBL_ZKEVM_TESTNET,
8564
+ ],
8565
+ [
8566
+ ChainId.IMTBL_ZKEVM_DEVNET,
8567
+ ChainName.IMTBL_ZKEVM_DEVNET,
8568
+ ],
8569
+ ]);
8570
+
8394
8571
  const MESSAGE_TO_SIGN = 'Only sign this message from Immutable Passport';
8395
- async function registerZkEvmUser({ authManager, config, magicProvider, multiRollupApiClients, accessToken, }) {
8572
+ async function registerZkEvmUser({ authManager, config, magicProvider, multiRollupApiClients, accessToken, jsonRpcProvider, }) {
8396
8573
  const web3Provider = new Web3Provider(magicProvider);
8397
8574
  const ethSigner = web3Provider.getSigner();
8398
8575
  const ethereumAddress = await ethSigner.getAddress();
8399
8576
  const ethereumSignature = await signRaw(MESSAGE_TO_SIGN, ethSigner);
8400
8577
  const headers = { Authorization: `Bearer ${accessToken}` };
8578
+ const { chainId } = await jsonRpcProvider.ready;
8401
8579
  try {
8580
+ const chainName = CHAIN_NAME_MAP.get(chainId);
8581
+ if (!chainName) {
8582
+ throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Chain name does not exist on for chain id ${chainId}`);
8583
+ }
8402
8584
  await multiRollupApiClients.passportApi.createCounterfactualAddress({
8585
+ chainName,
8403
8586
  createCounterfactualAddressRequest: {
8404
- ethereumAddress,
8405
- ethereumSignature,
8587
+ ethereum_address: ethereumAddress,
8588
+ ethereum_signature: ethereumSignature,
8406
8589
  },
8407
8590
  }, { headers });
8408
8591
  }
@@ -8426,7 +8609,7 @@ async function registerZkEvmUser({ authManager, config, magicProvider, multiRoll
8426
8609
  return user;
8427
8610
  }
8428
8611
 
8429
- const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, }) => {
8612
+ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupApiClients, jsonRpcProvider, }) => {
8430
8613
  const user = await authManager.getUser() || await authManager.getUserDeviceFlow() || await authManager.login();
8431
8614
  if (!user.idToken) {
8432
8615
  throw new Error('User is missing idToken');
@@ -8440,6 +8623,7 @@ const loginZkEvmUser = async ({ authManager, config, magicAdapter, multiRollupAp
8440
8623
  magicProvider,
8441
8624
  multiRollupApiClients,
8442
8625
  accessToken: user.accessToken,
8626
+ jsonRpcProvider,
8443
8627
  });
8444
8628
  return {
8445
8629
  user: userZkevm,
@@ -8654,6 +8838,7 @@ class ZkEvmProvider {
8654
8838
  config: this.config,
8655
8839
  magicAdapter: this.magicAdapter,
8656
8840
  multiRollupApiClients: this.multiRollupApiClients,
8841
+ jsonRpcProvider: this.jsonRpcProvider,
8657
8842
  });
8658
8843
  this.user = user;
8659
8844
  this.magicProvider = magicProvider;
@@ -8958,9 +9143,10 @@ class Passport {
8958
9143
  }
8959
9144
  const headers = { Authorization: `Bearer ${user.accessToken}` };
8960
9145
  const linkedAddressesResult = await this.multiRollupApiClients.passportApi.getLinkedAddresses({
9146
+ chainName: ChainName.ETHEREUM,
8961
9147
  userId: user?.profile.sub,
8962
9148
  }, { headers });
8963
- return linkedAddressesResult.data.linkedAddresses;
9149
+ return linkedAddressesResult.data.linked_addresses;
8964
9150
  }
8965
9151
  }
8966
9152
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.29.0-alpha.1",
4
+ "version": "0.30.0",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
@@ -36,9 +36,6 @@
36
36
  "oidc-client-ts": "^2.2.1",
37
37
  "os-browserify": "^0.3.0",
38
38
  "pako": "^2.1.0",
39
- "react": "^18.2.0",
40
- "react-dom": "^18.2.0",
41
- "react-router-dom": "^6.11.0",
42
39
  "stream-browserify": "^3.0.0",
43
40
  "stream-http": "^3.2.0",
44
41
  "url": "^0.11.0"