@imtbl/sdk 0.1.9-alpha → 0.1.9-alpha.2

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.
@@ -33,7 +33,7 @@ declare class Orderbook {
33
33
  * the unsigned approval transaction, the typed order message for signing and
34
34
  * the order components that can be submitted to `createListing` with a signature.
35
35
  */
36
- prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }: PrepareListingParams): Promise<PrepareListingResponse>;
36
+ prepareListing({ makerAddress, sell, buy, orderExpiry, }: PrepareListingParams): Promise<PrepareListingResponse>;
37
37
  /**
38
38
  * Create an order
39
39
  * @param {CreateListingParams} createListingParams - create an order with the given params.
@@ -48,7 +48,7 @@ declare class Orderbook {
48
48
  * @param {string} fulfillerAddress - The address of the account fulfilling the order.
49
49
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
50
50
  */
51
- fulfillOrder(listingId: string, fulfillerAddress: string): Promise<FulfillOrderResponse>;
51
+ fulfillOrder(listingId: string, takerAddress: string): Promise<FulfillOrderResponse>;
52
52
  /**
53
53
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
54
54
  * the account that created them.
package/dist/orderbook.js CHANGED
@@ -912,7 +912,7 @@ class ImmutableApiClient {
912
912
  ...listOrderParams,
913
913
  });
914
914
  }
915
- async createListing({ orderHash, orderComponents, offerer, orderSignature, }) {
915
+ async createListing({ orderHash, orderComponents, orderSignature, }) {
916
916
  if (orderComponents.offer.length !== 1) {
917
917
  throw new Error('Only one item can be listed at a time');
918
918
  }
@@ -930,7 +930,7 @@ class ImmutableApiClient {
930
930
  chainName: this.chainName,
931
931
  requestBody: {
932
932
  order_hash: orderHash,
933
- account_address: offerer,
933
+ account_address: orderComponents.offerer,
934
934
  buy: [
935
935
  {
936
936
  item_type: Number(orderComponents.consideration[0].itemType)
@@ -1961,10 +1961,10 @@ class Orderbook {
1961
1961
  * the unsigned approval transaction, the typed order message for signing and
1962
1962
  * the order components that can be submitted to `createListing` with a signature.
1963
1963
  */
1964
- async prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }) {
1965
- const erc721 = new ERC721Factory(listingItem.contractAddress, this.config.provider).create();
1966
- const royaltyInfo = await erc721.royaltyInfo(listingItem.tokenId, considerationItem.amount);
1967
- return this.seaport.prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo,
1964
+ async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
1965
+ const erc721 = new ERC721Factory(sell.contractAddress, this.config.provider).create();
1966
+ const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
1967
+ return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
1968
1968
  // Default order start to now
1969
1969
  new Date(),
1970
1970
  // Default order expiry to 2 years from now
@@ -1986,12 +1986,12 @@ class Orderbook {
1986
1986
  * @param {string} fulfillerAddress - The address of the account fulfilling the order.
1987
1987
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
1988
1988
  */
1989
- async fulfillOrder(listingId, fulfillerAddress) {
1989
+ async fulfillOrder(listingId, takerAddress) {
1990
1990
  const orderResult = await this.apiClient.getListing(listingId);
1991
1991
  if (orderResult.result.status !== OrderStatus.ACTIVE) {
1992
1992
  throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
1993
1993
  }
1994
- return this.seaport.fulfilOrder(orderResult.result, fulfillerAddress);
1994
+ return this.seaport.fulfilOrder(orderResult.result, takerAddress);
1995
1995
  }
1996
1996
  /**
1997
1997
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
@@ -10506,4 +10506,4 @@ declare class Passport {
10506
10506
  getAccessToken(): Promise<string | undefined>;
10507
10507
  }
10508
10508
 
10509
- export { Passport, PassportError, PassportModuleConfiguration };
10509
+ export { Networks, Passport, PassportError, PassportModuleConfiguration, PassportOverrides, UserProfile };
package/dist/passport.js CHANGED
@@ -21,7 +21,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
21
21
  chainID,
22
22
  coreContractAddress,
23
23
  registrationContractAddress,
24
- sdkVersion: 'ts-immutable-sdk-0.1.9-alpha',
24
+ sdkVersion: 'ts-immutable-sdk-0.1.9-alpha.2',
25
25
  });
26
26
  /**
27
27
  * Sets `sdkVersion` at the time of build
@@ -4283,7 +4283,7 @@ class AuthManager {
4283
4283
  }
4284
4284
  static mapOidcUserToDomainModel = (oidcUser) => {
4285
4285
  const passport = oidcUser.profile?.passport;
4286
- return {
4286
+ const user = {
4287
4287
  expired: oidcUser.expired,
4288
4288
  idToken: oidcUser.id_token,
4289
4289
  accessToken: oidcUser.access_token,
@@ -4293,10 +4293,21 @@ class AuthManager {
4293
4293
  email: oidcUser.profile.email,
4294
4294
  nickname: oidcUser.profile.nickname,
4295
4295
  },
4296
- etherKey: passport?.ether_key || '',
4297
- starkKey: passport?.stark_key || '',
4298
- userAdminKey: passport?.user_admin_key || '',
4299
4296
  };
4297
+ if (passport?.imx_eth_address) {
4298
+ user.imx = {
4299
+ ethAddress: passport?.imx_eth_address,
4300
+ starkAddress: passport?.imx_stark_address,
4301
+ userAdminAddress: passport?.imx_user_admin_address,
4302
+ };
4303
+ }
4304
+ if (passport?.zkevm_eth_address) {
4305
+ user.zkEvm = {
4306
+ ethAddress: passport?.zkevm_eth_address,
4307
+ userAdminAddress: passport?.zkevm_user_admin_address,
4308
+ };
4309
+ }
4310
+ return user;
4300
4311
  };
4301
4312
  async login() {
4302
4313
  return withPassportError(async () => {
@@ -4364,7 +4375,7 @@ const getStarkSigner = async (signer) => withPassportError(async () => {
4364
4375
 
4365
4376
  async function exchangeTransfer({ user, starkSigner, request, exchangesApi, }) {
4366
4377
  return withPassportError(async () => {
4367
- const ethAddress = user.etherKey;
4378
+ const { ethAddress } = user.imx;
4368
4379
  const transferAmount = request.amount;
4369
4380
  const signableResult = await exchangesApi.getExchangeSignableTransfer({
4370
4381
  id: request.transactionID,
@@ -4562,7 +4573,7 @@ class ConfirmationScreen {
4562
4573
  const ERC721$1 = 'ERC721';
4563
4574
  async function createOrder({ starkSigner, user, request, ordersApi, confirmationScreen, }) {
4564
4575
  return withPassportError(async () => {
4565
- const ethAddress = user.etherKey;
4576
+ const { ethAddress } = user.imx;
4566
4577
  const amountSell = request.sell.type === ERC721$1 ? '1' : request.sell.amount;
4567
4578
  const amountBuy = request.buy.type === ERC721$1 ? '1' : request.buy.amount;
4568
4579
  const getSignableOrderRequestV3 = {
@@ -4678,7 +4689,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
4678
4689
 
4679
4690
  async function createTrade({ request, tradesApi, user, starkSigner, confirmationScreen, }) {
4680
4691
  return withPassportError(async () => {
4681
- const ethAddress = user.etherKey;
4692
+ const { ethAddress } = user.imx;
4682
4693
  const getSignableTradeRequest = {
4683
4694
  expiration_timestamp: request.expiration_timestamp,
4684
4695
  fees: request.fees,
@@ -4788,7 +4799,7 @@ async function transfer({ request, transfersApi, starkSigner, user, imxPublicApi
4788
4799
  return withPassportError(async () => {
4789
4800
  const transferAmount = request.type === ERC721 ? '1' : request.amount;
4790
4801
  const getSignableTransferRequest = {
4791
- sender: user.etherKey,
4802
+ sender: user.imx.ethAddress,
4792
4803
  token: convertToSignableToken(request),
4793
4804
  amount: transferAmount,
4794
4805
  receiver: request.receiver,
@@ -4834,7 +4845,7 @@ async function transfer({ request, transfersApi, starkSigner, user, imxPublicApi
4834
4845
  }
4835
4846
  async function batchNftTransfer({ user, starkSigner, request, transfersApi, confirmationScreen, }) {
4836
4847
  return withPassportError(async () => {
4837
- const ethAddress = user.etherKey;
4848
+ const { ethAddress } = user.imx;
4838
4849
  const signableRequests = request.map((nftTransfer) => ({
4839
4850
  amount: '1',
4840
4851
  token: convertToSignableToken({
@@ -4986,7 +4997,7 @@ class PassportImxProvider {
4986
4997
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
4987
4998
  }
4988
4999
  getAddress() {
4989
- return Promise.resolve(this.user.etherKey);
5000
+ return Promise.resolve(this.user.imx.ethAddress);
4990
5001
  }
4991
5002
  }
4992
5003
 
@@ -5022,10 +5033,10 @@ class PassportImxProviderFactory {
5022
5033
  const web3Provider = new Web3Provider(magicRpcProvider);
5023
5034
  const ethSigner = web3Provider.getSigner();
5024
5035
  const starkSigner = await getStarkSigner(ethSigner);
5025
- if (!user.etherKey) {
5026
- const userWithEtherKey = await this.registerStarkEx(ethSigner, starkSigner, user.accessToken);
5036
+ if (!user.imx?.ethAddress) {
5037
+ const userImx = await this.registerStarkEx(ethSigner, starkSigner, user.accessToken);
5027
5038
  return new PassportImxProvider({
5028
- user: userWithEtherKey,
5039
+ user: userImx,
5029
5040
  starkSigner,
5030
5041
  immutableXClient: this.immutableXClient,
5031
5042
  imxPublicApiDomain: this.config.imxPublicApiDomain,
@@ -5050,7 +5061,7 @@ class PassportImxProviderFactory {
5050
5061
  // User metadata is updated asynchronously. Poll userinfo endpoint until it is updated.
5051
5062
  const updatedUser = await retryWithDelay(async () => {
5052
5063
  const user = await this.authManager.loginSilent();
5053
- const metadataExists = !!user?.etherKey && !!user?.starkKey && !!user?.userAdminKey;
5064
+ const metadataExists = !!user?.imx;
5054
5065
  if (metadataExists) {
5055
5066
  return user;
5056
5067
  }
@@ -5188,4 +5199,4 @@ class Passport {
5188
5199
  }
5189
5200
  }
5190
5201
 
5191
- export { Passport, PassportError };
5202
+ export { Networks, Passport, PassportError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.1.9-alpha",
4
+ "version": "0.1.9-alpha.2",
5
5
  "author": "Immutable",
6
6
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
7
7
  "dependencies": {