@imtbl/sdk 1.4.2 → 1.5.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/blockchain_data.js +2 -2
- package/dist/browser/checkout/sdk.js +4 -4
- package/dist/browser/checkout/widgets.js +50 -50
- package/dist/checkout.d.ts +45 -5
- package/dist/checkout.js +58 -10
- package/dist/config.js +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +100 -48
- package/dist/index.d.ts +58 -6
- package/dist/index.js +100 -48
- package/dist/orderbook.d.ts +6 -2
- package/dist/orderbook.js +3 -2
- package/dist/passport.js +43 -39
- package/dist/x.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -173,7 +173,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
176
|
-
const SDK_VERSION$1 = '1.
|
|
176
|
+
const SDK_VERSION$1 = '1.5.1';
|
|
177
177
|
let initialised$1 = false;
|
|
178
178
|
const isInitialised$1 = () => initialised$1;
|
|
179
179
|
const getReferrer$1 = () => {
|
|
@@ -11260,7 +11260,7 @@ class MultiRollupApiClients {
|
|
|
11260
11260
|
}
|
|
11261
11261
|
|
|
11262
11262
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11263
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.
|
|
11263
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.1' };
|
|
11264
11264
|
const createConfig = ({ basePath, headers, }) => {
|
|
11265
11265
|
if (!basePath.trim()) {
|
|
11266
11266
|
throw Error('basePath can not be empty');
|
|
@@ -11332,7 +11332,7 @@ class APIError extends Error {
|
|
|
11332
11332
|
|
|
11333
11333
|
/* eslint-disable implicit-arrow-linebreak */
|
|
11334
11334
|
const defaultHeaders = {
|
|
11335
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.
|
|
11335
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.1',
|
|
11336
11336
|
};
|
|
11337
11337
|
/**
|
|
11338
11338
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11765,7 +11765,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11765
11765
|
chainID,
|
|
11766
11766
|
coreContractAddress,
|
|
11767
11767
|
registrationContractAddress,
|
|
11768
|
-
sdkVersion: 'ts-immutable-sdk-1.
|
|
11768
|
+
sdkVersion: 'ts-immutable-sdk-1.5.1',
|
|
11769
11769
|
});
|
|
11770
11770
|
/**
|
|
11771
11771
|
* Sets `sdkVersion` at the time of build
|
|
@@ -16835,12 +16835,14 @@ class GuardianClient {
|
|
|
16835
16835
|
messageAPI;
|
|
16836
16836
|
confirmationScreen;
|
|
16837
16837
|
crossSdkBridgeEnabled;
|
|
16838
|
-
|
|
16838
|
+
authManager;
|
|
16839
|
+
constructor({ confirmationScreen, config, authManager }) {
|
|
16839
16840
|
const guardianConfiguration = new Configuration({ basePath: config.imxPublicApiDomain });
|
|
16840
16841
|
this.confirmationScreen = confirmationScreen;
|
|
16841
16842
|
this.crossSdkBridgeEnabled = config.crossSdkBridgeEnabled;
|
|
16842
16843
|
this.messageAPI = new MessagesApi(guardianConfiguration);
|
|
16843
16844
|
this.transactionAPI = new TransactionsApi(guardianConfiguration);
|
|
16845
|
+
this.authManager = authManager;
|
|
16844
16846
|
}
|
|
16845
16847
|
/**
|
|
16846
16848
|
* Open confirmation screen and close it automatically if the
|
|
@@ -16864,10 +16866,11 @@ class GuardianClient {
|
|
|
16864
16866
|
withDefaultConfirmationScreenTask(task) {
|
|
16865
16867
|
return this.withConfirmationScreenTask()(task);
|
|
16866
16868
|
}
|
|
16867
|
-
async evaluateImxTransaction({ payloadHash
|
|
16869
|
+
async evaluateImxTransaction({ payloadHash }) {
|
|
16868
16870
|
const finallyFn = () => {
|
|
16869
16871
|
this.confirmationScreen.closeWindow();
|
|
16870
16872
|
};
|
|
16873
|
+
const user = await this.authManager.getUser();
|
|
16871
16874
|
const headers = { Authorization: `Bearer ${user.accessToken}` };
|
|
16872
16875
|
const transactionRes = await retryWithDelay(async () => this.transactionAPI.getTransactionByID({
|
|
16873
16876
|
transactionID: payloadHash,
|
|
@@ -16896,7 +16899,8 @@ class GuardianClient {
|
|
|
16896
16899
|
this.confirmationScreen.closeWindow();
|
|
16897
16900
|
}
|
|
16898
16901
|
}
|
|
16899
|
-
async evaluateEVMTransaction({ chainId, nonce,
|
|
16902
|
+
async evaluateEVMTransaction({ chainId, nonce, metaTransactions, }) {
|
|
16903
|
+
const user = await this.authManager.getUser();
|
|
16900
16904
|
const headers = { Authorization: `Bearer ${user.accessToken}` };
|
|
16901
16905
|
const guardianTransactions = transformGuardianTransactions(metaTransactions);
|
|
16902
16906
|
try {
|
|
@@ -16919,11 +16923,10 @@ class GuardianClient {
|
|
|
16919
16923
|
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Transaction failed to validate with error: ${errorMessage}`);
|
|
16920
16924
|
}
|
|
16921
16925
|
}
|
|
16922
|
-
async validateEVMTransaction({ chainId, nonce,
|
|
16926
|
+
async validateEVMTransaction({ chainId, nonce, metaTransactions, }) {
|
|
16923
16927
|
const transactionEvaluationResponse = await this.evaluateEVMTransaction({
|
|
16924
16928
|
chainId,
|
|
16925
16929
|
nonce,
|
|
16926
|
-
user,
|
|
16927
16930
|
metaTransactions,
|
|
16928
16931
|
});
|
|
16929
16932
|
const { confirmationRequired, transactionId } = transactionEvaluationResponse;
|
|
@@ -16931,6 +16934,7 @@ class GuardianClient {
|
|
|
16931
16934
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
|
|
16932
16935
|
}
|
|
16933
16936
|
if (confirmationRequired && !!transactionId) {
|
|
16937
|
+
const user = await this.authManager.getUser();
|
|
16934
16938
|
const confirmationResult = await this.confirmationScreen.requestConfirmation(transactionId, user.zkEvm.ethAddress, TransactionApprovalRequestChainTypeEnum.Evm, chainId);
|
|
16935
16939
|
if (!confirmationResult.confirmed) {
|
|
16936
16940
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Transaction rejected by user');
|
|
@@ -16940,8 +16944,12 @@ class GuardianClient {
|
|
|
16940
16944
|
this.confirmationScreen.closeWindow();
|
|
16941
16945
|
}
|
|
16942
16946
|
}
|
|
16943
|
-
async evaluateMessage({ chainID, payload
|
|
16947
|
+
async evaluateMessage({ chainID, payload }) {
|
|
16944
16948
|
try {
|
|
16949
|
+
const user = await this.authManager.getUser();
|
|
16950
|
+
if (user === null) {
|
|
16951
|
+
throw new PassportError('evaluateMessage requires a valid ID token or refresh token. Please log in first', PassportErrorType.NOT_LOGGED_IN_ERROR);
|
|
16952
|
+
}
|
|
16945
16953
|
const messageEvalResponse = await this.messageAPI.evaluateMessage({ messageEvaluationRequest: { chainID, payload } }, { headers: { Authorization: `Bearer ${user.accessToken}` } });
|
|
16946
16954
|
return messageEvalResponse.data;
|
|
16947
16955
|
}
|
|
@@ -16950,12 +16958,13 @@ class GuardianClient {
|
|
|
16950
16958
|
throw new JsonRpcError(RpcErrorCode.INTERNAL_ERROR, `Message failed to validate with error: ${errorMessage}`);
|
|
16951
16959
|
}
|
|
16952
16960
|
}
|
|
16953
|
-
async validateMessage({ chainID, payload
|
|
16954
|
-
const { messageId, confirmationRequired } = await this.evaluateMessage({ chainID, payload
|
|
16961
|
+
async validateMessage({ chainID, payload }) {
|
|
16962
|
+
const { messageId, confirmationRequired } = await this.evaluateMessage({ chainID, payload });
|
|
16955
16963
|
if (confirmationRequired && this.crossSdkBridgeEnabled) {
|
|
16956
16964
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
|
|
16957
16965
|
}
|
|
16958
16966
|
if (confirmationRequired && !!messageId) {
|
|
16967
|
+
const user = await this.authManager.getUser();
|
|
16959
16968
|
const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress);
|
|
16960
16969
|
if (!confirmationResult.confirmed) {
|
|
16961
16970
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
|
|
@@ -17037,7 +17046,6 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, guardianCl
|
|
|
17037
17046
|
getSignableOrderRequestV3,
|
|
17038
17047
|
}, { headers });
|
|
17039
17048
|
await guardianClient.evaluateImxTransaction({
|
|
17040
|
-
user,
|
|
17041
17049
|
payloadHash: getSignableOrderResponse.data.payload_hash,
|
|
17042
17050
|
});
|
|
17043
17051
|
const { payload_hash: payloadHash } = getSignableOrderResponse.data;
|
|
@@ -17080,7 +17088,6 @@ async function cancelOrder$1({ user, starkSigner, request, ordersApi, guardianCl
|
|
|
17080
17088
|
getSignableCancelOrderRequest,
|
|
17081
17089
|
}, { headers });
|
|
17082
17090
|
await guardianClient.evaluateImxTransaction({
|
|
17083
|
-
user,
|
|
17084
17091
|
payloadHash: getSignableCancelOrderResponse.data.payload_hash,
|
|
17085
17092
|
});
|
|
17086
17093
|
const { payload_hash: payloadHash } = getSignableCancelOrderResponse.data;
|
|
@@ -17142,7 +17149,6 @@ async function createTrade$1({ request, tradesApi, user, starkSigner, guardianCl
|
|
|
17142
17149
|
getSignableTradeRequest,
|
|
17143
17150
|
}, { headers });
|
|
17144
17151
|
await guardianClient.evaluateImxTransaction({
|
|
17145
|
-
user,
|
|
17146
17152
|
payloadHash: getSignableTradeResponse.data.payload_hash,
|
|
17147
17153
|
});
|
|
17148
17154
|
const { payload_hash: payloadHash } = getSignableTradeResponse.data;
|
|
@@ -17190,7 +17196,6 @@ async function transfer$1({ request, transfersApi, starkSigner, user, guardianCl
|
|
|
17190
17196
|
getSignableTransferRequest,
|
|
17191
17197
|
}, { headers });
|
|
17192
17198
|
await guardianClient.evaluateImxTransaction({
|
|
17193
|
-
user,
|
|
17194
17199
|
payloadHash: signableResult.data.payload_hash,
|
|
17195
17200
|
});
|
|
17196
17201
|
const signableResultData = signableResult.data;
|
|
@@ -17241,7 +17246,6 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, guar
|
|
|
17241
17246
|
},
|
|
17242
17247
|
}, { headers });
|
|
17243
17248
|
await guardianClient.evaluateImxTransaction({
|
|
17244
|
-
user,
|
|
17245
17249
|
payloadHash: signableResult.data.signable_responses[0]?.payload_hash,
|
|
17246
17250
|
});
|
|
17247
17251
|
const requests = await Promise.all(signableResult.data.signable_responses.map(async (resp) => {
|
|
@@ -17321,6 +17325,7 @@ class PassportImxProvider {
|
|
|
17321
17325
|
this.guardianClient = new GuardianClient({
|
|
17322
17326
|
confirmationScreen,
|
|
17323
17327
|
config,
|
|
17328
|
+
authManager,
|
|
17324
17329
|
});
|
|
17325
17330
|
this.magicAdapter = magicAdapter;
|
|
17326
17331
|
this.imxApiClients = imxApiClients;
|
|
@@ -17952,11 +17957,11 @@ const getEip155ChainId = (chainId) => `eip155:${chainId}`;
|
|
|
17952
17957
|
class RelayerClient {
|
|
17953
17958
|
config;
|
|
17954
17959
|
jsonRpcProvider;
|
|
17955
|
-
|
|
17956
|
-
constructor({ config, jsonRpcProvider,
|
|
17960
|
+
authManager;
|
|
17961
|
+
constructor({ config, jsonRpcProvider, authManager }) {
|
|
17957
17962
|
this.config = config;
|
|
17958
17963
|
this.jsonRpcProvider = jsonRpcProvider;
|
|
17959
|
-
this.
|
|
17964
|
+
this.authManager = authManager;
|
|
17960
17965
|
}
|
|
17961
17966
|
async postToRelayer(request) {
|
|
17962
17967
|
const body = {
|
|
@@ -17964,10 +17969,11 @@ class RelayerClient {
|
|
|
17964
17969
|
jsonrpc: '2.0',
|
|
17965
17970
|
...request,
|
|
17966
17971
|
};
|
|
17972
|
+
const user = await this.authManager.getUser();
|
|
17967
17973
|
const response = await fetch(`${this.config.relayerUrl}/v1/transactions`, {
|
|
17968
17974
|
method: 'POST',
|
|
17969
17975
|
headers: {
|
|
17970
|
-
Authorization: `Bearer ${
|
|
17976
|
+
Authorization: `Bearer ${user?.accessToken}`,
|
|
17971
17977
|
'Content-Type': 'application/json',
|
|
17972
17978
|
},
|
|
17973
17979
|
body: JSON.stringify(body),
|
|
@@ -18126,7 +18132,7 @@ const getMetaTransactions = async (metaTransaction, nonce, chainId, walletAddres
|
|
|
18126
18132
|
}
|
|
18127
18133
|
return [metaTransaction, feeMetaTransaction];
|
|
18128
18134
|
};
|
|
18129
|
-
const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient,
|
|
18135
|
+
const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClient, guardianClient, zkevmAddress, }) => guardianClient
|
|
18130
18136
|
.withConfirmationScreen({ width: 480, height: 720 })(async () => {
|
|
18131
18137
|
const transactionRequest = params[0];
|
|
18132
18138
|
if (!transactionRequest.to) {
|
|
@@ -18136,7 +18142,7 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
|
|
|
18136
18142
|
const chainIdBigNumber = ethers.BigNumber.from(chainId);
|
|
18137
18143
|
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
18138
18144
|
const signer = magicWeb3Provider.getSigner();
|
|
18139
|
-
const nonce = await getNonce(jsonRpcProvider,
|
|
18145
|
+
const nonce = await getNonce(jsonRpcProvider, zkevmAddress);
|
|
18140
18146
|
const metaTransaction = {
|
|
18141
18147
|
to: transactionRequest.to,
|
|
18142
18148
|
data: transactionRequest.data,
|
|
@@ -18144,17 +18150,16 @@ const sendTransaction$1 = ({ params, magicProvider, jsonRpcProvider, relayerClie
|
|
|
18144
18150
|
value: transactionRequest.value,
|
|
18145
18151
|
revertOnError: true,
|
|
18146
18152
|
};
|
|
18147
|
-
const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber,
|
|
18153
|
+
const metaTransactions = await getMetaTransactions(metaTransaction, nonce, chainIdBigNumber, zkevmAddress, signer, relayerClient);
|
|
18148
18154
|
await guardianClient.validateEVMTransaction({
|
|
18149
18155
|
chainId: getEip155ChainId(chainId),
|
|
18150
18156
|
nonce: convertBigNumberishToString(nonce),
|
|
18151
|
-
user,
|
|
18152
18157
|
metaTransactions,
|
|
18153
18158
|
});
|
|
18154
18159
|
// NOTE: We sign again because we now are adding the fee transaction, so the
|
|
18155
18160
|
// whole payload is different and needs a new signature.
|
|
18156
|
-
const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber,
|
|
18157
|
-
const relayerId = await relayerClient.ethSendTransaction(
|
|
18161
|
+
const signedTransactions = await getSignedMetaTransactions(metaTransactions, nonce, chainIdBigNumber, zkevmAddress, signer);
|
|
18162
|
+
const relayerId = await relayerClient.ethSendTransaction(zkevmAddress, signedTransactions);
|
|
18158
18163
|
const retrieveRelayerTransaction = async () => {
|
|
18159
18164
|
const tx = await relayerClient.imGetTransactionByHash(relayerId);
|
|
18160
18165
|
// NOTE: The transaction hash is only available from the Relayer once the
|
|
@@ -18222,7 +18227,7 @@ const transformTypedData = (typedData, chainId) => {
|
|
|
18222
18227
|
}
|
|
18223
18228
|
return transformedTypedData;
|
|
18224
18229
|
};
|
|
18225
|
-
const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider, relayerClient, guardianClient,
|
|
18230
|
+
const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider, relayerClient, guardianClient, }) => guardianClient
|
|
18226
18231
|
.withConfirmationScreen({ width: 480, height: 730 })(async () => {
|
|
18227
18232
|
const fromAddress = params[0];
|
|
18228
18233
|
const typedDataParam = params[1];
|
|
@@ -18231,7 +18236,7 @@ const signTypedDataV4 = async ({ params, method, magicProvider, jsonRpcProvider,
|
|
|
18231
18236
|
}
|
|
18232
18237
|
const { chainId } = await jsonRpcProvider.ready;
|
|
18233
18238
|
const typedData = transformTypedData(typedDataParam, chainId);
|
|
18234
|
-
await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData
|
|
18239
|
+
await guardianClient.validateMessage({ chainID: String(chainId), payload: typedData });
|
|
18235
18240
|
const relayerSignature = await relayerClient.imSignTypedData(fromAddress, typedData);
|
|
18236
18241
|
const magicWeb3Provider = new providers.Web3Provider(magicProvider);
|
|
18237
18242
|
const signer = magicWeb3Provider.getSigner();
|
|
@@ -18249,7 +18254,7 @@ class ZkEvmProvider {
|
|
|
18249
18254
|
guardianClient;
|
|
18250
18255
|
relayerClient;
|
|
18251
18256
|
magicProvider; // Used for signing
|
|
18252
|
-
|
|
18257
|
+
zkevmAddress;
|
|
18253
18258
|
isPassport = true;
|
|
18254
18259
|
constructor({ authManager, magicAdapter, config, confirmationScreen, multiRollupApiClients, passportEventEmitter, }) {
|
|
18255
18260
|
this.authManager = authManager;
|
|
@@ -18274,7 +18279,6 @@ class ZkEvmProvider {
|
|
|
18274
18279
|
handleLogout = () => {
|
|
18275
18280
|
const shouldEmitAccountsChanged = this.isLoggedIn();
|
|
18276
18281
|
this.magicProvider = undefined;
|
|
18277
|
-
this.user = undefined;
|
|
18278
18282
|
this.relayerClient = undefined;
|
|
18279
18283
|
this.guardianClient = undefined;
|
|
18280
18284
|
if (shouldEmitAccountsChanged) {
|
|
@@ -18283,7 +18287,7 @@ class ZkEvmProvider {
|
|
|
18283
18287
|
};
|
|
18284
18288
|
isLoggedIn() {
|
|
18285
18289
|
return this.magicProvider !== undefined
|
|
18286
|
-
&& this.
|
|
18290
|
+
&& this.zkevmAddress !== undefined
|
|
18287
18291
|
&& this.relayerClient !== undefined
|
|
18288
18292
|
&& this.guardianClient !== undefined;
|
|
18289
18293
|
}
|
|
@@ -18291,7 +18295,7 @@ class ZkEvmProvider {
|
|
|
18291
18295
|
switch (request.method) {
|
|
18292
18296
|
case 'eth_requestAccounts': {
|
|
18293
18297
|
if (this.isLoggedIn()) {
|
|
18294
|
-
return [this.
|
|
18298
|
+
return [this.zkevmAddress];
|
|
18295
18299
|
}
|
|
18296
18300
|
const { magicProvider, user } = await loginZkEvmUser({
|
|
18297
18301
|
authManager: this.authManager,
|
|
@@ -18300,19 +18304,20 @@ class ZkEvmProvider {
|
|
|
18300
18304
|
multiRollupApiClients: this.multiRollupApiClients,
|
|
18301
18305
|
jsonRpcProvider: this.jsonRpcProvider,
|
|
18302
18306
|
});
|
|
18303
|
-
this.user = user;
|
|
18304
18307
|
this.magicProvider = magicProvider;
|
|
18305
18308
|
this.relayerClient = new RelayerClient({
|
|
18306
18309
|
config: this.config,
|
|
18307
18310
|
jsonRpcProvider: this.jsonRpcProvider,
|
|
18308
|
-
|
|
18311
|
+
authManager: this.authManager,
|
|
18309
18312
|
});
|
|
18310
18313
|
this.guardianClient = new GuardianClient({
|
|
18311
18314
|
confirmationScreen: this.confirmationScreen,
|
|
18312
18315
|
config: this.config,
|
|
18316
|
+
authManager: this.authManager,
|
|
18313
18317
|
});
|
|
18314
|
-
this.
|
|
18315
|
-
|
|
18318
|
+
this.zkevmAddress = user.zkEvm.ethAddress;
|
|
18319
|
+
this.eventEmitter.emit(ProviderEvent.ACCOUNTS_CHANGED, [user.zkEvm.ethAddress]);
|
|
18320
|
+
return [user.zkEvm.ethAddress];
|
|
18316
18321
|
}
|
|
18317
18322
|
case 'eth_sendTransaction': {
|
|
18318
18323
|
if (!this.isLoggedIn()) {
|
|
@@ -18324,11 +18329,11 @@ class ZkEvmProvider {
|
|
|
18324
18329
|
guardianClient: this.guardianClient,
|
|
18325
18330
|
jsonRpcProvider: this.jsonRpcProvider,
|
|
18326
18331
|
relayerClient: this.relayerClient,
|
|
18327
|
-
|
|
18332
|
+
zkevmAddress: this.zkevmAddress,
|
|
18328
18333
|
});
|
|
18329
18334
|
}
|
|
18330
18335
|
case 'eth_accounts': {
|
|
18331
|
-
return this.
|
|
18336
|
+
return this.zkevmAddress ? [this.zkevmAddress] : [];
|
|
18332
18337
|
}
|
|
18333
18338
|
case 'eth_signTypedData':
|
|
18334
18339
|
case 'eth_signTypedData_v4': {
|
|
@@ -18341,7 +18346,6 @@ class ZkEvmProvider {
|
|
|
18341
18346
|
magicProvider: this.magicProvider,
|
|
18342
18347
|
jsonRpcProvider: this.jsonRpcProvider,
|
|
18343
18348
|
relayerClient: this.relayerClient,
|
|
18344
|
-
user: this.user,
|
|
18345
18349
|
guardianClient: this.guardianClient,
|
|
18346
18350
|
});
|
|
18347
18351
|
}
|
|
@@ -19089,7 +19093,7 @@ class OrdersService {
|
|
|
19089
19093
|
* @returns ListListingsResult OK response.
|
|
19090
19094
|
* @throws ApiError
|
|
19091
19095
|
*/
|
|
19092
|
-
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
19096
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemType, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
19093
19097
|
return this.httpRequest.request({
|
|
19094
19098
|
method: 'GET',
|
|
19095
19099
|
url: '/v1/chains/{chain_name}/orders/listings',
|
|
@@ -19099,6 +19103,7 @@ class OrdersService {
|
|
|
19099
19103
|
query: {
|
|
19100
19104
|
'status': status,
|
|
19101
19105
|
'sell_item_contract_address': sellItemContractAddress,
|
|
19106
|
+
'buy_item_type': buyItemType,
|
|
19102
19107
|
'buy_item_contract_address': buyItemContractAddress,
|
|
19103
19108
|
'account_address': accountAddress,
|
|
19104
19109
|
'sell_item_metadata_id': sellItemMetadataId,
|
|
@@ -37061,7 +37066,7 @@ const flattenProperties = (properties) => {
|
|
|
37061
37066
|
};
|
|
37062
37067
|
|
|
37063
37068
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
37064
|
-
const SDK_VERSION = '1.
|
|
37069
|
+
const SDK_VERSION = '1.5.1';
|
|
37065
37070
|
let initialised = false;
|
|
37066
37071
|
const isInitialised = () => initialised;
|
|
37067
37072
|
const getReferrer = () => {
|
|
@@ -42169,7 +42174,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
42169
42174
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
42170
42175
|
};
|
|
42171
42176
|
|
|
42172
|
-
const SDK_VERSION_MARKER = '1.
|
|
42177
|
+
const SDK_VERSION_MARKER = '1.5.1';
|
|
42173
42178
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
42174
42179
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
42175
42180
|
|
|
@@ -45431,9 +45436,7 @@ const buy = async (config, provider, orders, overrides = {
|
|
|
45431
45436
|
};
|
|
45432
45437
|
};
|
|
45433
45438
|
|
|
45434
|
-
const
|
|
45435
|
-
waitFulfillmentSettlements: true,
|
|
45436
|
-
}) => {
|
|
45439
|
+
const cancelOnChain = async (config, orderbook, provider, orderIds, waitFulfillmentSettlements) => {
|
|
45437
45440
|
let unsignedCancelOrderTransaction;
|
|
45438
45441
|
if (orderIds.length === 0) {
|
|
45439
45442
|
throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
|
|
@@ -45442,7 +45445,6 @@ const cancel = async (config, provider, orderIds, overrides = {
|
|
|
45442
45445
|
const orderId = orderIds[0];
|
|
45443
45446
|
try {
|
|
45444
45447
|
const offererAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
|
|
45445
|
-
const orderbook = createOrderbookInstance(config);
|
|
45446
45448
|
const cancelOrderResponse = await measureAsyncExecution(config, 'Time to get the cancel order from the orderbook', orderbook.cancelOrdersOnChain([orderId], offererAddress));
|
|
45447
45449
|
unsignedCancelOrderTransaction = await cancelOrderResponse.cancellationAction.buildTransaction();
|
|
45448
45450
|
}
|
|
@@ -45452,7 +45454,7 @@ const cancel = async (config, provider, orderIds, overrides = {
|
|
|
45452
45454
|
error: err,
|
|
45453
45455
|
});
|
|
45454
45456
|
}
|
|
45455
|
-
if (
|
|
45457
|
+
if (waitFulfillmentSettlements) {
|
|
45456
45458
|
const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
|
|
45457
45459
|
if (result.type === SignTransactionStatusType.FAILED) {
|
|
45458
45460
|
return {
|
|
@@ -45480,6 +45482,56 @@ const cancel = async (config, provider, orderIds, overrides = {
|
|
|
45480
45482
|
transactions,
|
|
45481
45483
|
};
|
|
45482
45484
|
};
|
|
45485
|
+
const gaslessCancel = async (orderbook, provider, orderIds) => {
|
|
45486
|
+
try {
|
|
45487
|
+
const signer = provider.getSigner();
|
|
45488
|
+
const address = await signer.getAddress();
|
|
45489
|
+
const { signableAction } = await orderbook.prepareOrderCancellations(orderIds);
|
|
45490
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
45491
|
+
const signedMessage = await signer._signTypedData(signableAction.message.domain, signableAction.message.types, signableAction.message.value);
|
|
45492
|
+
const { result } = await orderbook.cancelOrders(orderIds, address, signedMessage);
|
|
45493
|
+
const successfulCancellations = [];
|
|
45494
|
+
const failedCancellations = [];
|
|
45495
|
+
const pendingCancellations = [];
|
|
45496
|
+
for (const success of result.successful_cancellations) {
|
|
45497
|
+
successfulCancellations.push({
|
|
45498
|
+
orderId: success,
|
|
45499
|
+
});
|
|
45500
|
+
}
|
|
45501
|
+
for (const failed of result.failed_cancellations) {
|
|
45502
|
+
failedCancellations.push({
|
|
45503
|
+
orderId: failed.order,
|
|
45504
|
+
reason: failed.reason_code,
|
|
45505
|
+
});
|
|
45506
|
+
}
|
|
45507
|
+
for (const pending of result.pending_cancellations) {
|
|
45508
|
+
pendingCancellations.push({
|
|
45509
|
+
orderId: pending,
|
|
45510
|
+
});
|
|
45511
|
+
}
|
|
45512
|
+
return {
|
|
45513
|
+
successfulCancellations,
|
|
45514
|
+
failedCancellations,
|
|
45515
|
+
pendingCancellations,
|
|
45516
|
+
};
|
|
45517
|
+
}
|
|
45518
|
+
catch (err) {
|
|
45519
|
+
throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
|
|
45520
|
+
orderIds,
|
|
45521
|
+
error: err,
|
|
45522
|
+
});
|
|
45523
|
+
}
|
|
45524
|
+
};
|
|
45525
|
+
const cancel = async (config, provider, orderIds, overrides = {
|
|
45526
|
+
waitFulfillmentSettlements: true,
|
|
45527
|
+
useGaslessCancel: false,
|
|
45528
|
+
}) => {
|
|
45529
|
+
const orderbook = createOrderbookInstance(config);
|
|
45530
|
+
if (overrides.useGaslessCancel) {
|
|
45531
|
+
return await gaslessCancel(orderbook, provider, orderIds);
|
|
45532
|
+
}
|
|
45533
|
+
return await cancelOnChain(config, orderbook, provider, orderIds, overrides.waitFulfillmentSettlements ?? true);
|
|
45534
|
+
};
|
|
45483
45535
|
|
|
45484
45536
|
const getERC721Requirement = (id, contractAddress, spenderAddress) => ({
|
|
45485
45537
|
type: ItemType.ERC721,
|
package/dist/index.d.ts
CHANGED
|
@@ -29148,7 +29148,7 @@ type FulfillmentDataRequest = {
|
|
|
29148
29148
|
/**
|
|
29149
29149
|
* Address of the intended account fulfilling the order
|
|
29150
29150
|
*/
|
|
29151
|
-
taker_address
|
|
29151
|
+
taker_address: string;
|
|
29152
29152
|
fees: Array<Fee$2>;
|
|
29153
29153
|
};
|
|
29154
29154
|
|
|
@@ -29279,7 +29279,7 @@ declare class OrdersService {
|
|
|
29279
29279
|
* @returns ListListingsResult OK response.
|
|
29280
29280
|
* @throws ApiError
|
|
29281
29281
|
*/
|
|
29282
|
-
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }: {
|
|
29282
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemType, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }: {
|
|
29283
29283
|
chainName: ChainName$1;
|
|
29284
29284
|
/**
|
|
29285
29285
|
* Order status to filter by
|
|
@@ -29289,6 +29289,10 @@ declare class OrdersService {
|
|
|
29289
29289
|
* Sell item contract address to filter by
|
|
29290
29290
|
*/
|
|
29291
29291
|
sellItemContractAddress?: string;
|
|
29292
|
+
/**
|
|
29293
|
+
* Buy item type to filter by
|
|
29294
|
+
*/
|
|
29295
|
+
buyItemType?: 'NATIVE' | 'ERC20';
|
|
29292
29296
|
/**
|
|
29293
29297
|
* Buy item contract address to filter by
|
|
29294
29298
|
*/
|
|
@@ -30088,7 +30092,7 @@ type SellResultInsufficientFunds = {
|
|
|
30088
30092
|
/** The insufficient result of smart checkout */
|
|
30089
30093
|
smartCheckoutResult: SmartCheckoutInsufficient;
|
|
30090
30094
|
};
|
|
30091
|
-
type CancelResult = CancelResultSuccess | CancelResultFailed | CancelResultFulfillmentsUnsettled;
|
|
30095
|
+
type CancelResult = CancelResultSuccess | CancelResultFailed | CancelResultFulfillmentsUnsettled | CancelResultGasless;
|
|
30092
30096
|
/**
|
|
30093
30097
|
* Represents the result of {@link Checkout.cancel}
|
|
30094
30098
|
* @property {CheckoutStatus.SUCCESS} status
|
|
@@ -30117,18 +30121,58 @@ type CancelResultFailed = {
|
|
|
30117
30121
|
* @property {SendTransactionResult[]} transactions
|
|
30118
30122
|
*/
|
|
30119
30123
|
type CancelResultFulfillmentsUnsettled = {
|
|
30120
|
-
/** The status to indicate
|
|
30124
|
+
/** The status to indicate the fulfillments have not yet settled on chain. */
|
|
30121
30125
|
status: CheckoutStatus.FULFILLMENTS_UNSETTLED;
|
|
30122
30126
|
/** Array of transaction results */
|
|
30123
30127
|
transactions: TransactionResponse[];
|
|
30124
30128
|
};
|
|
30129
|
+
/**
|
|
30130
|
+
* Represents the result of {@link Checkout.cancel} when using gasless cancel
|
|
30131
|
+
* @property {SuccessfulGaslessCancellation[]} successfulCancellations
|
|
30132
|
+
* @property {FailedGaslessCancellation[]} failedCancellations
|
|
30133
|
+
* @property {PendingGaslessCancellation[]} pendingCancellations
|
|
30134
|
+
*/
|
|
30135
|
+
type CancelResultGasless = {
|
|
30136
|
+
successfulCancellations: SuccessfulGaslessCancellation[];
|
|
30137
|
+
failedCancellations: FailedGaslessCancellation[];
|
|
30138
|
+
pendingCancellations: PendingGaslessCancellation[];
|
|
30139
|
+
};
|
|
30140
|
+
/**
|
|
30141
|
+
* Represents a successful gasless cancellation
|
|
30142
|
+
* @property {string} orderId
|
|
30143
|
+
*/
|
|
30144
|
+
type SuccessfulGaslessCancellation = {
|
|
30145
|
+
/** The order id of the successful cancellation */
|
|
30146
|
+
orderId: string;
|
|
30147
|
+
};
|
|
30148
|
+
/**
|
|
30149
|
+
* Represents a failed gasless cancellation
|
|
30150
|
+
* @property {string} orderId
|
|
30151
|
+
* @property {string} reason
|
|
30152
|
+
*/
|
|
30153
|
+
type FailedGaslessCancellation = {
|
|
30154
|
+
/** The order id of the failed cancellation */
|
|
30155
|
+
orderId: string;
|
|
30156
|
+
/** The reason for failure */
|
|
30157
|
+
reason: string;
|
|
30158
|
+
};
|
|
30159
|
+
/**
|
|
30160
|
+
* Represents a pending gasless cancellation
|
|
30161
|
+
* @property {string} orderId
|
|
30162
|
+
*/
|
|
30163
|
+
type PendingGaslessCancellation = {
|
|
30164
|
+
/** The order id of the pending cancellation */
|
|
30165
|
+
orderId: string;
|
|
30166
|
+
};
|
|
30125
30167
|
/**
|
|
30126
30168
|
* Represents the overrides available for {@link Checkout.cancel}
|
|
30127
30169
|
* @property {boolean} waitFulfillmentSettlements
|
|
30128
30170
|
*/
|
|
30129
30171
|
type CancelOverrides = {
|
|
30130
|
-
/** If the
|
|
30172
|
+
/** If the cancel should wait for the fulfillment transactions to settle */
|
|
30131
30173
|
waitFulfillmentSettlements?: boolean;
|
|
30174
|
+
/** If the cancel should use the gasless option */
|
|
30175
|
+
useGaslessCancel?: boolean;
|
|
30132
30176
|
};
|
|
30133
30177
|
/**
|
|
30134
30178
|
* An enum representing the checkout status types
|
|
@@ -30147,7 +30191,7 @@ declare enum CheckoutStatus {
|
|
|
30147
30191
|
/**
|
|
30148
30192
|
* The type representing the order to buy
|
|
30149
30193
|
* @property {string} orderId
|
|
30150
|
-
* @property {
|
|
30194
|
+
* @property {OrderFee[]} takerFees
|
|
30151
30195
|
*/
|
|
30152
30196
|
type BuyOrder = {
|
|
30153
30197
|
/** the id of the order to buy */
|
|
@@ -32492,6 +32536,7 @@ type checkout_d_CancelParams = CancelParams;
|
|
|
32492
32536
|
type checkout_d_CancelResult = CancelResult;
|
|
32493
32537
|
type checkout_d_CancelResultFailed = CancelResultFailed;
|
|
32494
32538
|
type checkout_d_CancelResultFulfillmentsUnsettled = CancelResultFulfillmentsUnsettled;
|
|
32539
|
+
type checkout_d_CancelResultGasless = CancelResultGasless;
|
|
32495
32540
|
type checkout_d_CancelResultSuccess = CancelResultSuccess;
|
|
32496
32541
|
type checkout_d_ChainId = ChainId;
|
|
32497
32542
|
declare const checkout_d_ChainId: typeof ChainId;
|
|
@@ -32533,6 +32578,7 @@ type checkout_d_ERC721ItemRequirement = ERC721ItemRequirement;
|
|
|
32533
32578
|
type checkout_d_ErrorType = ErrorType;
|
|
32534
32579
|
type checkout_d_ExchangeType = ExchangeType;
|
|
32535
32580
|
declare const checkout_d_ExchangeType: typeof ExchangeType;
|
|
32581
|
+
type checkout_d_FailedGaslessCancellation = FailedGaslessCancellation;
|
|
32536
32582
|
type checkout_d_Fee = Fee;
|
|
32537
32583
|
type checkout_d_FeePercentage = FeePercentage;
|
|
32538
32584
|
type checkout_d_FeeToken = FeeToken;
|
|
@@ -32595,6 +32641,7 @@ type checkout_d_OrchestrationEventData = OrchestrationEventData;
|
|
|
32595
32641
|
type checkout_d_OrchestrationEventType = OrchestrationEventType;
|
|
32596
32642
|
declare const checkout_d_OrchestrationEventType: typeof OrchestrationEventType;
|
|
32597
32643
|
type checkout_d_OrderFee = OrderFee;
|
|
32644
|
+
type checkout_d_PendingGaslessCancellation = PendingGaslessCancellation;
|
|
32598
32645
|
type checkout_d_ProviderEvent<KEventName extends keyof ProviderEventMapping> = ProviderEvent<KEventName>;
|
|
32599
32646
|
type checkout_d_ProviderEventType = ProviderEventType;
|
|
32600
32647
|
declare const checkout_d_ProviderEventType: typeof ProviderEventType;
|
|
@@ -32635,6 +32682,7 @@ type checkout_d_SmartCheckoutParams = SmartCheckoutParams;
|
|
|
32635
32682
|
type checkout_d_SmartCheckoutResult = SmartCheckoutResult;
|
|
32636
32683
|
type checkout_d_SmartCheckoutRouter = SmartCheckoutRouter;
|
|
32637
32684
|
type checkout_d_SmartCheckoutSufficient = SmartCheckoutSufficient;
|
|
32685
|
+
type checkout_d_SuccessfulGaslessCancellation = SuccessfulGaslessCancellation;
|
|
32638
32686
|
type checkout_d_SwapEventType = SwapEventType;
|
|
32639
32687
|
declare const checkout_d_SwapEventType: typeof SwapEventType;
|
|
32640
32688
|
type checkout_d_SwapFailed = SwapFailed;
|
|
@@ -32707,6 +32755,7 @@ declare namespace checkout_d {
|
|
|
32707
32755
|
checkout_d_CancelResult as CancelResult,
|
|
32708
32756
|
checkout_d_CancelResultFailed as CancelResultFailed,
|
|
32709
32757
|
checkout_d_CancelResultFulfillmentsUnsettled as CancelResultFulfillmentsUnsettled,
|
|
32758
|
+
checkout_d_CancelResultGasless as CancelResultGasless,
|
|
32710
32759
|
checkout_d_CancelResultSuccess as CancelResultSuccess,
|
|
32711
32760
|
checkout_d_ChainId as ChainId,
|
|
32712
32761
|
checkout_d_ChainName as ChainName,
|
|
@@ -32738,6 +32787,7 @@ declare namespace checkout_d {
|
|
|
32738
32787
|
checkout_d_ERC721ItemRequirement as ERC721ItemRequirement,
|
|
32739
32788
|
checkout_d_ErrorType as ErrorType,
|
|
32740
32789
|
checkout_d_ExchangeType as ExchangeType,
|
|
32790
|
+
checkout_d_FailedGaslessCancellation as FailedGaslessCancellation,
|
|
32741
32791
|
checkout_d_Fee as Fee,
|
|
32742
32792
|
checkout_d_FeePercentage as FeePercentage,
|
|
32743
32793
|
checkout_d_FeeToken as FeeToken,
|
|
@@ -32791,6 +32841,7 @@ declare namespace checkout_d {
|
|
|
32791
32841
|
checkout_d_OrchestrationEventData as OrchestrationEventData,
|
|
32792
32842
|
checkout_d_OrchestrationEventType as OrchestrationEventType,
|
|
32793
32843
|
checkout_d_OrderFee as OrderFee,
|
|
32844
|
+
checkout_d_PendingGaslessCancellation as PendingGaslessCancellation,
|
|
32794
32845
|
checkout_d_ProviderEvent as ProviderEvent,
|
|
32795
32846
|
checkout_d_ProviderEventType as ProviderEventType,
|
|
32796
32847
|
checkout_d_ProviderUpdated as ProviderUpdated,
|
|
@@ -32827,6 +32878,7 @@ declare namespace checkout_d {
|
|
|
32827
32878
|
checkout_d_SmartCheckoutResult as SmartCheckoutResult,
|
|
32828
32879
|
checkout_d_SmartCheckoutRouter as SmartCheckoutRouter,
|
|
32829
32880
|
checkout_d_SmartCheckoutSufficient as SmartCheckoutSufficient,
|
|
32881
|
+
checkout_d_SuccessfulGaslessCancellation as SuccessfulGaslessCancellation,
|
|
32830
32882
|
checkout_d_SwapEventType as SwapEventType,
|
|
32831
32883
|
checkout_d_SwapFailed as SwapFailed,
|
|
32832
32884
|
checkout_d_SwapFundingStep as SwapFundingStep,
|