@myx-trade/sdk 0.1.79 → 0.1.81
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/index.d.mts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.js +51 -34
- package/dist/index.mjs +51 -34
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1184,6 +1184,11 @@ interface AccessTokenResponse {
|
|
|
1184
1184
|
interface MyxClientConfig {
|
|
1185
1185
|
chainId: number;
|
|
1186
1186
|
signer?: Signer;
|
|
1187
|
+
seamlessAccount?: {
|
|
1188
|
+
masterAddress: string;
|
|
1189
|
+
wallet: ethers$1.Wallet | null;
|
|
1190
|
+
authorized: boolean;
|
|
1191
|
+
};
|
|
1187
1192
|
walletClient?: WalletClient;
|
|
1188
1193
|
brokerAddress: string;
|
|
1189
1194
|
isTestnet?: boolean;
|
|
@@ -1200,7 +1205,12 @@ declare class ConfigManager {
|
|
|
1200
1205
|
constructor(config: MyxClientConfig);
|
|
1201
1206
|
clear(): void;
|
|
1202
1207
|
startSeamlessMode(open: boolean): void;
|
|
1203
|
-
|
|
1208
|
+
updateSeamlessWallet({ wallet, authorized, masterAddress }: {
|
|
1209
|
+
wallet?: ethers$1.Wallet;
|
|
1210
|
+
authorized?: boolean;
|
|
1211
|
+
masterAddress?: string;
|
|
1212
|
+
}): void;
|
|
1213
|
+
updateClientChainId(chainId: number, brokerAddress: string): void;
|
|
1204
1214
|
auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
|
|
1205
1215
|
private validateConfig;
|
|
1206
1216
|
/**
|
|
@@ -1514,9 +1524,6 @@ declare class Seamless {
|
|
|
1514
1524
|
private logger;
|
|
1515
1525
|
private utils;
|
|
1516
1526
|
private account;
|
|
1517
|
-
seamlessWallet: ethers$1.Wallet | null;
|
|
1518
|
-
private seamlessWalletAuthorized;
|
|
1519
|
-
private seamlessWalletApikey;
|
|
1520
1527
|
constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account);
|
|
1521
1528
|
onCheckRelayer(account: string, relayer: string): Promise<boolean>;
|
|
1522
1529
|
getUSDPermitParams(deadline: number): Promise<{
|
|
@@ -1759,7 +1766,7 @@ declare class MyxClient {
|
|
|
1759
1766
|
* auth the client
|
|
1760
1767
|
*/
|
|
1761
1768
|
auth(params: Required<Pick<MyxClientConfig, "signer" | "getAccessToken" | "walletClient">>): void;
|
|
1762
|
-
updateClientChainId(chainId: number): void;
|
|
1769
|
+
updateClientChainId(chainId: number, brokerAddress: string): void;
|
|
1763
1770
|
/**
|
|
1764
1771
|
* close the client
|
|
1765
1772
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1184,6 +1184,11 @@ interface AccessTokenResponse {
|
|
|
1184
1184
|
interface MyxClientConfig {
|
|
1185
1185
|
chainId: number;
|
|
1186
1186
|
signer?: Signer;
|
|
1187
|
+
seamlessAccount?: {
|
|
1188
|
+
masterAddress: string;
|
|
1189
|
+
wallet: ethers$1.Wallet | null;
|
|
1190
|
+
authorized: boolean;
|
|
1191
|
+
};
|
|
1187
1192
|
walletClient?: WalletClient;
|
|
1188
1193
|
brokerAddress: string;
|
|
1189
1194
|
isTestnet?: boolean;
|
|
@@ -1200,7 +1205,12 @@ declare class ConfigManager {
|
|
|
1200
1205
|
constructor(config: MyxClientConfig);
|
|
1201
1206
|
clear(): void;
|
|
1202
1207
|
startSeamlessMode(open: boolean): void;
|
|
1203
|
-
|
|
1208
|
+
updateSeamlessWallet({ wallet, authorized, masterAddress }: {
|
|
1209
|
+
wallet?: ethers$1.Wallet;
|
|
1210
|
+
authorized?: boolean;
|
|
1211
|
+
masterAddress?: string;
|
|
1212
|
+
}): void;
|
|
1213
|
+
updateClientChainId(chainId: number, brokerAddress: string): void;
|
|
1204
1214
|
auth(params: Pick<MyxClientConfig, "signer" | "getAccessToken">): void;
|
|
1205
1215
|
private validateConfig;
|
|
1206
1216
|
/**
|
|
@@ -1514,9 +1524,6 @@ declare class Seamless {
|
|
|
1514
1524
|
private logger;
|
|
1515
1525
|
private utils;
|
|
1516
1526
|
private account;
|
|
1517
|
-
seamlessWallet: ethers$1.Wallet | null;
|
|
1518
|
-
private seamlessWalletAuthorized;
|
|
1519
|
-
private seamlessWalletApikey;
|
|
1520
1527
|
constructor(configManager: ConfigManager, logger: Logger, utils: Utils, account: Account);
|
|
1521
1528
|
onCheckRelayer(account: string, relayer: string): Promise<boolean>;
|
|
1522
1529
|
getUSDPermitParams(deadline: number): Promise<{
|
|
@@ -1759,7 +1766,7 @@ declare class MyxClient {
|
|
|
1759
1766
|
* auth the client
|
|
1760
1767
|
*/
|
|
1761
1768
|
auth(params: Required<Pick<MyxClientConfig, "signer" | "getAccessToken" | "walletClient">>): void;
|
|
1762
|
-
updateClientChainId(chainId: number): void;
|
|
1769
|
+
updateClientChainId(chainId: number, brokerAddress: string): void;
|
|
1763
1770
|
/**
|
|
1764
1771
|
* close the client
|
|
1765
1772
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1841,7 +1841,7 @@ var RotationProvider = class extends import_providers.BaseProvider {
|
|
|
1841
1841
|
// package.json
|
|
1842
1842
|
var package_default = {
|
|
1843
1843
|
name: "@myx-trade/sdk",
|
|
1844
|
-
version: "0.1.
|
|
1844
|
+
version: "0.1.81",
|
|
1845
1845
|
private: false,
|
|
1846
1846
|
publishConfig: {
|
|
1847
1847
|
access: "public"
|
|
@@ -13668,10 +13668,21 @@ var ConfigManager = class {
|
|
|
13668
13668
|
seamlessMode: open
|
|
13669
13669
|
};
|
|
13670
13670
|
}
|
|
13671
|
-
|
|
13671
|
+
updateSeamlessWallet({ wallet, authorized, masterAddress }) {
|
|
13672
13672
|
this.config = {
|
|
13673
13673
|
...this.config,
|
|
13674
|
-
|
|
13674
|
+
seamlessAccount: {
|
|
13675
|
+
masterAddress: masterAddress ?? "",
|
|
13676
|
+
wallet: wallet ?? null,
|
|
13677
|
+
authorized: authorized ?? false
|
|
13678
|
+
}
|
|
13679
|
+
};
|
|
13680
|
+
}
|
|
13681
|
+
updateClientChainId(chainId, brokerAddress) {
|
|
13682
|
+
this.config = {
|
|
13683
|
+
...this.config,
|
|
13684
|
+
chainId,
|
|
13685
|
+
brokerAddress
|
|
13675
13686
|
};
|
|
13676
13687
|
}
|
|
13677
13688
|
auth(params) {
|
|
@@ -14347,12 +14358,9 @@ var Order = class {
|
|
|
14347
14358
|
useAccountBalance: false
|
|
14348
14359
|
};
|
|
14349
14360
|
this.logger.info("createIncreaseOrder position params--->", data);
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
throw new MyxSDKError("INVALID_SEAMLESS_WALLET" /* InvalidSeamlessWallet */, "Invalid seamless wallet");
|
|
14354
|
-
}
|
|
14355
|
-
console.log("seamlessWallet-->", seamlessWallet);
|
|
14361
|
+
const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
|
|
14362
|
+
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14363
|
+
if (config.seamlessMode && authorized && seamlessWallet) {
|
|
14356
14364
|
const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
|
|
14357
14365
|
if (!isEnoughGas) {
|
|
14358
14366
|
throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
|
|
@@ -14361,7 +14369,7 @@ var Order = class {
|
|
|
14361
14369
|
const forwarderContract = await getForwarderContract(params.chainId);
|
|
14362
14370
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14363
14371
|
this.configManager.getConfig().brokerAddress,
|
|
14364
|
-
|
|
14372
|
+
seamlessWallet
|
|
14365
14373
|
);
|
|
14366
14374
|
let functionHash = "";
|
|
14367
14375
|
if (!params.positionId) {
|
|
@@ -14382,7 +14390,7 @@ var Order = class {
|
|
|
14382
14390
|
}
|
|
14383
14391
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14384
14392
|
const forwardTxParams = {
|
|
14385
|
-
from:
|
|
14393
|
+
from: seamlessWallet.address ?? "",
|
|
14386
14394
|
to: this.configManager.getConfig().brokerAddress,
|
|
14387
14395
|
value: "0",
|
|
14388
14396
|
gas: "350000",
|
|
@@ -14391,7 +14399,7 @@ var Order = class {
|
|
|
14391
14399
|
nonce: nonce.toString()
|
|
14392
14400
|
};
|
|
14393
14401
|
this.logger.info("createIncreaseOrder forward tx params --->", forwardTxParams);
|
|
14394
|
-
const rs = await this.seamless.forwarderTx(forwardTxParams,
|
|
14402
|
+
const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
|
|
14395
14403
|
console.log("rs-->", rs);
|
|
14396
14404
|
return {
|
|
14397
14405
|
code: 0,
|
|
@@ -19472,14 +19480,16 @@ var Utils = class {
|
|
|
19472
19480
|
async getUserTradingFeeRate(assetClass) {
|
|
19473
19481
|
const config = this.configManager.getConfig();
|
|
19474
19482
|
const brokerAddress = config.brokerAddress;
|
|
19475
|
-
const brokerContract = new import_ethers25.ethers.Contract(
|
|
19476
|
-
brokerAddress,
|
|
19477
|
-
Broker_default,
|
|
19478
|
-
config.signer
|
|
19479
|
-
);
|
|
19480
19483
|
try {
|
|
19484
|
+
const provider = await getJSONProvider(config.chainId);
|
|
19485
|
+
const brokerContract = new import_ethers25.ethers.Contract(
|
|
19486
|
+
brokerAddress,
|
|
19487
|
+
Broker_default,
|
|
19488
|
+
provider
|
|
19489
|
+
);
|
|
19490
|
+
const targetAddress = config.seamlessMode ? config.seamlessAccount?.masterAddress : config.signer?.getAddress();
|
|
19481
19491
|
const userFeeRate = await brokerContract.getUserFeeRate(
|
|
19482
|
-
|
|
19492
|
+
targetAddress,
|
|
19483
19493
|
assetClass
|
|
19484
19494
|
);
|
|
19485
19495
|
return {
|
|
@@ -19505,10 +19515,11 @@ var Utils = class {
|
|
|
19505
19515
|
const orderManagerAddress = getContractAddressByChainId(
|
|
19506
19516
|
config.chainId
|
|
19507
19517
|
).ORDER_MANAGER;
|
|
19518
|
+
const provider = await getJSONProvider(config.chainId);
|
|
19508
19519
|
const orderManagerContract = new import_ethers25.ethers.Contract(
|
|
19509
19520
|
orderManagerAddress,
|
|
19510
19521
|
OrderManager_default,
|
|
19511
|
-
|
|
19522
|
+
provider
|
|
19512
19523
|
);
|
|
19513
19524
|
try {
|
|
19514
19525
|
const networkFee = await orderManagerContract.getExecutionFee(
|
|
@@ -20633,14 +20644,14 @@ async function signPermit(provider, contract, owner, spender, value, nonce, dead
|
|
|
20633
20644
|
return { v, r, s };
|
|
20634
20645
|
}
|
|
20635
20646
|
var Seamless = class {
|
|
20647
|
+
// public seamlessWallet: ethers.Wallet | null
|
|
20648
|
+
// private seamlessWalletAuthorized: boolean
|
|
20649
|
+
// private seamlessWalletApikey: string
|
|
20636
20650
|
constructor(configManager, logger, utils, account) {
|
|
20637
20651
|
this.configManager = configManager;
|
|
20638
20652
|
this.logger = logger;
|
|
20639
20653
|
this.utils = utils;
|
|
20640
20654
|
this.account = account;
|
|
20641
|
-
this.seamlessWallet = null;
|
|
20642
|
-
this.seamlessWalletAuthorized = false;
|
|
20643
|
-
this.seamlessWalletApikey = "";
|
|
20644
20655
|
}
|
|
20645
20656
|
async onCheckRelayer(account, relayer) {
|
|
20646
20657
|
const config = this.configManager.getConfig();
|
|
@@ -20815,9 +20826,12 @@ var Seamless = class {
|
|
|
20815
20826
|
});
|
|
20816
20827
|
const privateKey = decrypted.toString(import_crypto_js.default.enc.Utf8);
|
|
20817
20828
|
const wallet = new import_ethers27.ethers.Wallet(privateKey);
|
|
20818
|
-
this.seamlessWallet = wallet;
|
|
20819
20829
|
const isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address);
|
|
20820
|
-
this.
|
|
20830
|
+
this.configManager.updateSeamlessWallet({
|
|
20831
|
+
masterAddress,
|
|
20832
|
+
wallet,
|
|
20833
|
+
authorized: isAuthorized
|
|
20834
|
+
});
|
|
20821
20835
|
return {
|
|
20822
20836
|
code: 0,
|
|
20823
20837
|
data: {
|
|
@@ -20837,8 +20851,7 @@ var Seamless = class {
|
|
|
20837
20851
|
});
|
|
20838
20852
|
const privateKey = decrypted.toString(import_crypto_js.default.enc.Utf8);
|
|
20839
20853
|
const wallet = new import_ethers27.ethers.Wallet(privateKey);
|
|
20840
|
-
|
|
20841
|
-
if (wallet.address !== this.seamlessWallet?.address) {
|
|
20854
|
+
if (wallet.address !== this.configManager.getConfig().seamlessAccount?.wallet?.address) {
|
|
20842
20855
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key");
|
|
20843
20856
|
}
|
|
20844
20857
|
return {
|
|
@@ -20868,9 +20881,11 @@ var Seamless = class {
|
|
|
20868
20881
|
padding: import_crypto_js.default.pad.Pkcs7
|
|
20869
20882
|
});
|
|
20870
20883
|
const apiKey = encrypted.toString();
|
|
20871
|
-
this.
|
|
20872
|
-
|
|
20873
|
-
|
|
20884
|
+
this.configManager.updateSeamlessWallet({
|
|
20885
|
+
masterAddress,
|
|
20886
|
+
wallet,
|
|
20887
|
+
authorized: isAuthorized
|
|
20888
|
+
});
|
|
20874
20889
|
return {
|
|
20875
20890
|
code: 0,
|
|
20876
20891
|
data: {
|
|
@@ -20910,9 +20925,11 @@ var Seamless = class {
|
|
|
20910
20925
|
});
|
|
20911
20926
|
const apiKey = encrypted.toString();
|
|
20912
20927
|
let isAuthorized = await this.onCheckRelayer(account, wallet.address);
|
|
20913
|
-
this.
|
|
20914
|
-
|
|
20915
|
-
|
|
20928
|
+
this.configManager.updateSeamlessWallet({
|
|
20929
|
+
masterAddress: account,
|
|
20930
|
+
wallet,
|
|
20931
|
+
authorized: isAuthorized
|
|
20932
|
+
});
|
|
20916
20933
|
const forwarderContract = await getForwarderContract(config.chainId);
|
|
20917
20934
|
const erc20Address = getContractAddressByChainId(config.chainId).ERC20;
|
|
20918
20935
|
await this.utils.approveAuthorization({
|
|
@@ -20967,8 +20984,8 @@ var MyxClient = class {
|
|
|
20967
20984
|
auth(params) {
|
|
20968
20985
|
this.configManager.auth(params);
|
|
20969
20986
|
}
|
|
20970
|
-
updateClientChainId(chainId) {
|
|
20971
|
-
this.configManager.updateClientChainId(chainId);
|
|
20987
|
+
updateClientChainId(chainId, brokerAddress) {
|
|
20988
|
+
this.configManager.updateClientChainId(chainId, brokerAddress);
|
|
20972
20989
|
}
|
|
20973
20990
|
/**
|
|
20974
20991
|
* close the client
|
package/dist/index.mjs
CHANGED
|
@@ -1752,7 +1752,7 @@ var RotationProvider = class extends BaseProvider {
|
|
|
1752
1752
|
// package.json
|
|
1753
1753
|
var package_default = {
|
|
1754
1754
|
name: "@myx-trade/sdk",
|
|
1755
|
-
version: "0.1.
|
|
1755
|
+
version: "0.1.81",
|
|
1756
1756
|
private: false,
|
|
1757
1757
|
publishConfig: {
|
|
1758
1758
|
access: "public"
|
|
@@ -13579,10 +13579,21 @@ var ConfigManager = class {
|
|
|
13579
13579
|
seamlessMode: open
|
|
13580
13580
|
};
|
|
13581
13581
|
}
|
|
13582
|
-
|
|
13582
|
+
updateSeamlessWallet({ wallet, authorized, masterAddress }) {
|
|
13583
13583
|
this.config = {
|
|
13584
13584
|
...this.config,
|
|
13585
|
-
|
|
13585
|
+
seamlessAccount: {
|
|
13586
|
+
masterAddress: masterAddress ?? "",
|
|
13587
|
+
wallet: wallet ?? null,
|
|
13588
|
+
authorized: authorized ?? false
|
|
13589
|
+
}
|
|
13590
|
+
};
|
|
13591
|
+
}
|
|
13592
|
+
updateClientChainId(chainId, brokerAddress) {
|
|
13593
|
+
this.config = {
|
|
13594
|
+
...this.config,
|
|
13595
|
+
chainId,
|
|
13596
|
+
brokerAddress
|
|
13586
13597
|
};
|
|
13587
13598
|
}
|
|
13588
13599
|
auth(params) {
|
|
@@ -14258,12 +14269,9 @@ var Order = class {
|
|
|
14258
14269
|
useAccountBalance: false
|
|
14259
14270
|
};
|
|
14260
14271
|
this.logger.info("createIncreaseOrder position params--->", data);
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
throw new MyxSDKError("INVALID_SEAMLESS_WALLET" /* InvalidSeamlessWallet */, "Invalid seamless wallet");
|
|
14265
|
-
}
|
|
14266
|
-
console.log("seamlessWallet-->", seamlessWallet);
|
|
14272
|
+
const authorized = this.configManager.getConfig().seamlessAccount?.authorized;
|
|
14273
|
+
const seamlessWallet = this.configManager.getConfig().seamlessAccount?.wallet;
|
|
14274
|
+
if (config.seamlessMode && authorized && seamlessWallet) {
|
|
14267
14275
|
const isEnoughGas = await this.utils.checkSeamlessGas(params.address);
|
|
14268
14276
|
if (!isEnoughGas) {
|
|
14269
14277
|
throw new MyxSDKError("INSUFFICIENT_BALANCE" /* InsufficientBalance */, "Insufficient relay fee");
|
|
@@ -14272,7 +14280,7 @@ var Order = class {
|
|
|
14272
14280
|
const forwarderContract = await getForwarderContract(params.chainId);
|
|
14273
14281
|
const brokerContract2 = await getSeamlessBrokerContract(
|
|
14274
14282
|
this.configManager.getConfig().brokerAddress,
|
|
14275
|
-
|
|
14283
|
+
seamlessWallet
|
|
14276
14284
|
);
|
|
14277
14285
|
let functionHash = "";
|
|
14278
14286
|
if (!params.positionId) {
|
|
@@ -14293,7 +14301,7 @@ var Order = class {
|
|
|
14293
14301
|
}
|
|
14294
14302
|
const nonce = await forwarderContract.nonces(seamlessWallet.address);
|
|
14295
14303
|
const forwardTxParams = {
|
|
14296
|
-
from:
|
|
14304
|
+
from: seamlessWallet.address ?? "",
|
|
14297
14305
|
to: this.configManager.getConfig().brokerAddress,
|
|
14298
14306
|
value: "0",
|
|
14299
14307
|
gas: "350000",
|
|
@@ -14302,7 +14310,7 @@ var Order = class {
|
|
|
14302
14310
|
nonce: nonce.toString()
|
|
14303
14311
|
};
|
|
14304
14312
|
this.logger.info("createIncreaseOrder forward tx params --->", forwardTxParams);
|
|
14305
|
-
const rs = await this.seamless.forwarderTx(forwardTxParams,
|
|
14313
|
+
const rs = await this.seamless.forwarderTx(forwardTxParams, seamlessWallet);
|
|
14306
14314
|
console.log("rs-->", rs);
|
|
14307
14315
|
return {
|
|
14308
14316
|
code: 0,
|
|
@@ -19383,14 +19391,16 @@ var Utils = class {
|
|
|
19383
19391
|
async getUserTradingFeeRate(assetClass) {
|
|
19384
19392
|
const config = this.configManager.getConfig();
|
|
19385
19393
|
const brokerAddress = config.brokerAddress;
|
|
19386
|
-
const brokerContract = new ethers7.Contract(
|
|
19387
|
-
brokerAddress,
|
|
19388
|
-
Broker_default,
|
|
19389
|
-
config.signer
|
|
19390
|
-
);
|
|
19391
19394
|
try {
|
|
19395
|
+
const provider = await getJSONProvider(config.chainId);
|
|
19396
|
+
const brokerContract = new ethers7.Contract(
|
|
19397
|
+
brokerAddress,
|
|
19398
|
+
Broker_default,
|
|
19399
|
+
provider
|
|
19400
|
+
);
|
|
19401
|
+
const targetAddress = config.seamlessMode ? config.seamlessAccount?.masterAddress : config.signer?.getAddress();
|
|
19392
19402
|
const userFeeRate = await brokerContract.getUserFeeRate(
|
|
19393
|
-
|
|
19403
|
+
targetAddress,
|
|
19394
19404
|
assetClass
|
|
19395
19405
|
);
|
|
19396
19406
|
return {
|
|
@@ -19416,10 +19426,11 @@ var Utils = class {
|
|
|
19416
19426
|
const orderManagerAddress = getContractAddressByChainId(
|
|
19417
19427
|
config.chainId
|
|
19418
19428
|
).ORDER_MANAGER;
|
|
19429
|
+
const provider = await getJSONProvider(config.chainId);
|
|
19419
19430
|
const orderManagerContract = new ethers7.Contract(
|
|
19420
19431
|
orderManagerAddress,
|
|
19421
19432
|
OrderManager_default,
|
|
19422
|
-
|
|
19433
|
+
provider
|
|
19423
19434
|
);
|
|
19424
19435
|
try {
|
|
19425
19436
|
const networkFee = await orderManagerContract.getExecutionFee(
|
|
@@ -20544,14 +20555,14 @@ async function signPermit(provider, contract, owner, spender, value, nonce, dead
|
|
|
20544
20555
|
return { v, r, s };
|
|
20545
20556
|
}
|
|
20546
20557
|
var Seamless = class {
|
|
20558
|
+
// public seamlessWallet: ethers.Wallet | null
|
|
20559
|
+
// private seamlessWalletAuthorized: boolean
|
|
20560
|
+
// private seamlessWalletApikey: string
|
|
20547
20561
|
constructor(configManager, logger, utils, account) {
|
|
20548
20562
|
this.configManager = configManager;
|
|
20549
20563
|
this.logger = logger;
|
|
20550
20564
|
this.utils = utils;
|
|
20551
20565
|
this.account = account;
|
|
20552
|
-
this.seamlessWallet = null;
|
|
20553
|
-
this.seamlessWalletAuthorized = false;
|
|
20554
|
-
this.seamlessWalletApikey = "";
|
|
20555
20566
|
}
|
|
20556
20567
|
async onCheckRelayer(account, relayer) {
|
|
20557
20568
|
const config = this.configManager.getConfig();
|
|
@@ -20726,9 +20737,12 @@ var Seamless = class {
|
|
|
20726
20737
|
});
|
|
20727
20738
|
const privateKey = decrypted.toString(CryptoJS.enc.Utf8);
|
|
20728
20739
|
const wallet = new ethers9.Wallet(privateKey);
|
|
20729
|
-
this.seamlessWallet = wallet;
|
|
20730
20740
|
const isAuthorized = await this.onCheckRelayer(masterAddress, wallet.address);
|
|
20731
|
-
this.
|
|
20741
|
+
this.configManager.updateSeamlessWallet({
|
|
20742
|
+
masterAddress,
|
|
20743
|
+
wallet,
|
|
20744
|
+
authorized: isAuthorized
|
|
20745
|
+
});
|
|
20732
20746
|
return {
|
|
20733
20747
|
code: 0,
|
|
20734
20748
|
data: {
|
|
@@ -20748,8 +20762,7 @@ var Seamless = class {
|
|
|
20748
20762
|
});
|
|
20749
20763
|
const privateKey = decrypted.toString(CryptoJS.enc.Utf8);
|
|
20750
20764
|
const wallet = new ethers9.Wallet(privateKey);
|
|
20751
|
-
|
|
20752
|
-
if (wallet.address !== this.seamlessWallet?.address) {
|
|
20765
|
+
if (wallet.address !== this.configManager.getConfig().seamlessAccount?.wallet?.address) {
|
|
20753
20766
|
throw new MyxSDKError("INVALID_PRIVATE_KEY" /* InvalidPrivateKey */, "Invalid private key");
|
|
20754
20767
|
}
|
|
20755
20768
|
return {
|
|
@@ -20779,9 +20792,11 @@ var Seamless = class {
|
|
|
20779
20792
|
padding: CryptoJS.pad.Pkcs7
|
|
20780
20793
|
});
|
|
20781
20794
|
const apiKey = encrypted.toString();
|
|
20782
|
-
this.
|
|
20783
|
-
|
|
20784
|
-
|
|
20795
|
+
this.configManager.updateSeamlessWallet({
|
|
20796
|
+
masterAddress,
|
|
20797
|
+
wallet,
|
|
20798
|
+
authorized: isAuthorized
|
|
20799
|
+
});
|
|
20785
20800
|
return {
|
|
20786
20801
|
code: 0,
|
|
20787
20802
|
data: {
|
|
@@ -20821,9 +20836,11 @@ var Seamless = class {
|
|
|
20821
20836
|
});
|
|
20822
20837
|
const apiKey = encrypted.toString();
|
|
20823
20838
|
let isAuthorized = await this.onCheckRelayer(account, wallet.address);
|
|
20824
|
-
this.
|
|
20825
|
-
|
|
20826
|
-
|
|
20839
|
+
this.configManager.updateSeamlessWallet({
|
|
20840
|
+
masterAddress: account,
|
|
20841
|
+
wallet,
|
|
20842
|
+
authorized: isAuthorized
|
|
20843
|
+
});
|
|
20827
20844
|
const forwarderContract = await getForwarderContract(config.chainId);
|
|
20828
20845
|
const erc20Address = getContractAddressByChainId(config.chainId).ERC20;
|
|
20829
20846
|
await this.utils.approveAuthorization({
|
|
@@ -20878,8 +20895,8 @@ var MyxClient = class {
|
|
|
20878
20895
|
auth(params) {
|
|
20879
20896
|
this.configManager.auth(params);
|
|
20880
20897
|
}
|
|
20881
|
-
updateClientChainId(chainId) {
|
|
20882
|
-
this.configManager.updateClientChainId(chainId);
|
|
20898
|
+
updateClientChainId(chainId, brokerAddress) {
|
|
20899
|
+
this.configManager.updateClientChainId(chainId, brokerAddress);
|
|
20883
20900
|
}
|
|
20884
20901
|
/**
|
|
20885
20902
|
* close the client
|