@imtbl/sdk 0.1.6 → 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/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +986 -0
- package/dist/checkout_sdk.js +734 -0
- package/dist/checkout_widgets.d.ts +15485 -0
- package/dist/checkout_widgets.js +284 -0
- package/dist/immutablex_client.js +2 -2
- package/dist/index.cjs +3943 -24
- package/dist/index.d.ts +17171 -299
- package/dist/index.js +3932 -29
- package/dist/orderbook.d.ts +57 -0
- package/dist/orderbook.js +1833 -0
- package/dist/passport.d.ts +1154 -1
- package/dist/passport.js +18 -13
- package/dist/provider.d.ts +961 -0
- package/dist/provider.js +1143 -0
- package/package.json +27 -2
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.
|
|
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.
|
|
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
|
-
?
|
|
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
|
-
|
|
538
|
+
const removedHexPrefixSig = encUtils.removeHexPrefix(sig);
|
|
536
539
|
return {
|
|
537
|
-
r: new BN(
|
|
538
|
-
s: new BN(
|
|
539
|
-
recoveryParam: importRecoveryParam(
|
|
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.
|
|
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;
|