@weblock-wallet/sdk 0.1.52 → 0.1.54
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.cjs +179 -525
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -87
- package/dist/index.d.ts +36 -87
- package/dist/index.js +179 -525
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -105236,6 +105236,44 @@ var ERC20_ABI2 = [
|
|
|
105236
105236
|
type: "function"
|
|
105237
105237
|
}
|
|
105238
105238
|
];
|
|
105239
|
+
var ERC1155_ABI = [
|
|
105240
|
+
{
|
|
105241
|
+
constant: true,
|
|
105242
|
+
inputs: [
|
|
105243
|
+
{ name: "account", type: "address" },
|
|
105244
|
+
{ name: "id", type: "uint256" }
|
|
105245
|
+
],
|
|
105246
|
+
name: "balanceOf",
|
|
105247
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
105248
|
+
payable: false,
|
|
105249
|
+
stateMutability: "view",
|
|
105250
|
+
type: "function"
|
|
105251
|
+
}
|
|
105252
|
+
];
|
|
105253
|
+
var RBT_PROPERTY_TOKEN_ABI = [
|
|
105254
|
+
...ERC1155_ABI,
|
|
105255
|
+
{
|
|
105256
|
+
constant: true,
|
|
105257
|
+
inputs: [
|
|
105258
|
+
{ name: "tokenId", type: "uint256" },
|
|
105259
|
+
{ name: "account", type: "address" }
|
|
105260
|
+
],
|
|
105261
|
+
name: "claimable",
|
|
105262
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
105263
|
+
payable: false,
|
|
105264
|
+
stateMutability: "view",
|
|
105265
|
+
type: "function"
|
|
105266
|
+
},
|
|
105267
|
+
{
|
|
105268
|
+
constant: false,
|
|
105269
|
+
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
105270
|
+
name: "claim",
|
|
105271
|
+
outputs: [],
|
|
105272
|
+
payable: false,
|
|
105273
|
+
stateMutability: "nonpayable",
|
|
105274
|
+
type: "function"
|
|
105275
|
+
}
|
|
105276
|
+
];
|
|
105239
105277
|
|
|
105240
105278
|
// src/core/services/asset.ts
|
|
105241
105279
|
var import_ethers3 = require("ethers");
|
|
@@ -105920,6 +105958,7 @@ var AssetService = class extends EventEmitter {
|
|
|
105920
105958
|
this.orgHost = orgHost;
|
|
105921
105959
|
this.chainIdCache = /* @__PURE__ */ new Map();
|
|
105922
105960
|
this.erc20Interface = new import_ethers3.Interface(ERC20_ABI2);
|
|
105961
|
+
this.rbtInterface = new import_ethers3.Interface(RBT_PROPERTY_TOKEN_ABI);
|
|
105923
105962
|
}
|
|
105924
105963
|
/**
|
|
105925
105964
|
* Resolve a user-facing networkId (blockchainId) into an EVM chainId for /v1/rpcs.
|
|
@@ -106217,21 +106256,116 @@ var AssetService = class extends EventEmitter {
|
|
|
106217
106256
|
);
|
|
106218
106257
|
}
|
|
106219
106258
|
}
|
|
106220
|
-
|
|
106259
|
+
/**
|
|
106260
|
+
* ERC-1155 balanceOf(account, tokenId)
|
|
106261
|
+
* - Returns raw hex string (0x...)
|
|
106262
|
+
*/
|
|
106263
|
+
async getERC1155Balance(params) {
|
|
106221
106264
|
try {
|
|
106222
106265
|
const chainId = await this.resolveChainId(params.networkId);
|
|
106223
|
-
const data = this.
|
|
106224
|
-
params.
|
|
106225
|
-
params.
|
|
106266
|
+
const data = this.rbtInterface.encodeFunctionData("balanceOf", [
|
|
106267
|
+
params.walletAddress,
|
|
106268
|
+
params.tokenId
|
|
106269
|
+
]);
|
|
106270
|
+
const response = await this.rpcClient.sendRpc({
|
|
106271
|
+
chainId,
|
|
106272
|
+
method: "eth_call" /* ETH_CALL */,
|
|
106273
|
+
params: [
|
|
106274
|
+
{
|
|
106275
|
+
to: params.tokenAddress,
|
|
106276
|
+
data
|
|
106277
|
+
},
|
|
106278
|
+
"latest"
|
|
106279
|
+
]
|
|
106280
|
+
});
|
|
106281
|
+
return response.result;
|
|
106282
|
+
} catch (error) {
|
|
106283
|
+
throw new SDKError(
|
|
106284
|
+
"Failed to get ERC1155 balance",
|
|
106285
|
+
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106286
|
+
error
|
|
106287
|
+
);
|
|
106288
|
+
}
|
|
106289
|
+
}
|
|
106290
|
+
/**
|
|
106291
|
+
* RBTPropertyToken claimable(tokenId, account)
|
|
106292
|
+
* - Returns raw hex string (0x...)
|
|
106293
|
+
*/
|
|
106294
|
+
async getRbtClaimable(params) {
|
|
106295
|
+
try {
|
|
106296
|
+
const chainId = await this.resolveChainId(params.networkId);
|
|
106297
|
+
const data = this.rbtInterface.encodeFunctionData("claimable", [
|
|
106298
|
+
params.tokenId,
|
|
106299
|
+
params.walletAddress
|
|
106300
|
+
]);
|
|
106301
|
+
const response = await this.rpcClient.sendRpc({
|
|
106302
|
+
chainId,
|
|
106303
|
+
method: "eth_call" /* ETH_CALL */,
|
|
106304
|
+
params: [
|
|
106305
|
+
{
|
|
106306
|
+
to: params.tokenAddress,
|
|
106307
|
+
data
|
|
106308
|
+
},
|
|
106309
|
+
"latest"
|
|
106310
|
+
]
|
|
106311
|
+
});
|
|
106312
|
+
return response.result;
|
|
106313
|
+
} catch (error) {
|
|
106314
|
+
throw new SDKError(
|
|
106315
|
+
"Failed to get claimable amount",
|
|
106316
|
+
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106317
|
+
error
|
|
106318
|
+
);
|
|
106319
|
+
}
|
|
106320
|
+
}
|
|
106321
|
+
/**
|
|
106322
|
+
* RBTPropertyToken claim(tokenId)
|
|
106323
|
+
* - Sends a signed transaction via WalletService
|
|
106324
|
+
* - Returns txHash
|
|
106325
|
+
*/
|
|
106326
|
+
async claimRbt(params) {
|
|
106327
|
+
try {
|
|
106328
|
+
const chainId = await this.resolveChainId(params.networkId);
|
|
106329
|
+
const data = this.rbtInterface.encodeFunctionData("claim", [
|
|
106330
|
+
params.tokenId
|
|
106226
106331
|
]);
|
|
106227
106332
|
const txHash = await this.walletService.sendTransaction({
|
|
106228
106333
|
to: params.tokenAddress,
|
|
106229
106334
|
value: "0",
|
|
106230
106335
|
data,
|
|
106231
|
-
chainId
|
|
106336
|
+
chainId,
|
|
106337
|
+
gasLimit: params.gasLimit,
|
|
106338
|
+
gasPrice: params.gasPrice,
|
|
106339
|
+
nonce: params.nonce
|
|
106232
106340
|
});
|
|
106233
106341
|
this.trackTransaction(txHash, chainId);
|
|
106234
106342
|
return txHash;
|
|
106343
|
+
} catch (error) {
|
|
106344
|
+
throw new SDKError(
|
|
106345
|
+
"Failed to claim RBT",
|
|
106346
|
+
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106347
|
+
error
|
|
106348
|
+
);
|
|
106349
|
+
}
|
|
106350
|
+
}
|
|
106351
|
+
async approveToken(params) {
|
|
106352
|
+
try {
|
|
106353
|
+
const chainId = await this.resolveChainId(params.networkId);
|
|
106354
|
+
const data = this.erc20Interface.encodeFunctionData("approve", [
|
|
106355
|
+
params.spender,
|
|
106356
|
+
params.amount
|
|
106357
|
+
]);
|
|
106358
|
+
const response = await this.rpcClient.sendRpc({
|
|
106359
|
+
chainId,
|
|
106360
|
+
method: "eth_sendRawTransaction" /* ETH_SEND_RAW_TRANSACTION */,
|
|
106361
|
+
params: [
|
|
106362
|
+
{
|
|
106363
|
+
to: params.tokenAddress,
|
|
106364
|
+
data
|
|
106365
|
+
}
|
|
106366
|
+
]
|
|
106367
|
+
});
|
|
106368
|
+
return response.result;
|
|
106235
106369
|
} catch (error) {
|
|
106236
106370
|
throw new SDKError(
|
|
106237
106371
|
"Failed to approve token",
|
|
@@ -106314,402 +106448,6 @@ var AssetService = class extends EventEmitter {
|
|
|
106314
106448
|
// }
|
|
106315
106449
|
};
|
|
106316
106450
|
|
|
106317
|
-
// src/core/services/investment.ts
|
|
106318
|
-
var import_ethers4 = require("ethers");
|
|
106319
|
-
|
|
106320
|
-
// src/contract/weblock.ts
|
|
106321
|
-
var RBT_PRIMARY_SALE_ROUTER_ABI = [
|
|
106322
|
-
{
|
|
106323
|
-
inputs: [{ name: "offeringId", type: "uint256" }],
|
|
106324
|
-
name: "offerings",
|
|
106325
|
-
outputs: [
|
|
106326
|
-
{ name: "asset", type: "address" },
|
|
106327
|
-
{ name: "seriesId", type: "uint256" },
|
|
106328
|
-
{ name: "unitPrice", type: "uint256" },
|
|
106329
|
-
{ name: "remainingUnits", type: "uint256" },
|
|
106330
|
-
{ name: "startAt", type: "uint64" },
|
|
106331
|
-
{ name: "endAt", type: "uint64" },
|
|
106332
|
-
{ name: "treasury", type: "address" },
|
|
106333
|
-
{ name: "enabled", type: "bool" }
|
|
106334
|
-
],
|
|
106335
|
-
stateMutability: "view",
|
|
106336
|
-
type: "function"
|
|
106337
|
-
},
|
|
106338
|
-
{
|
|
106339
|
-
inputs: [
|
|
106340
|
-
{ name: "offeringId", type: "uint256" },
|
|
106341
|
-
{ name: "units", type: "uint256" },
|
|
106342
|
-
{ name: "maxCost", type: "uint256" }
|
|
106343
|
-
],
|
|
106344
|
-
name: "buy",
|
|
106345
|
-
outputs: [],
|
|
106346
|
-
stateMutability: "nonpayable",
|
|
106347
|
-
type: "function"
|
|
106348
|
-
}
|
|
106349
|
-
];
|
|
106350
|
-
var RBT_PROPERTY_TOKEN_ABI = [
|
|
106351
|
-
{
|
|
106352
|
-
inputs: [
|
|
106353
|
-
{ name: "account", type: "address" },
|
|
106354
|
-
{ name: "id", type: "uint256" }
|
|
106355
|
-
],
|
|
106356
|
-
name: "balanceOf",
|
|
106357
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
106358
|
-
stateMutability: "view",
|
|
106359
|
-
type: "function"
|
|
106360
|
-
},
|
|
106361
|
-
{
|
|
106362
|
-
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
106363
|
-
name: "claim",
|
|
106364
|
-
outputs: [],
|
|
106365
|
-
stateMutability: "nonpayable",
|
|
106366
|
-
type: "function"
|
|
106367
|
-
},
|
|
106368
|
-
{
|
|
106369
|
-
inputs: [
|
|
106370
|
-
{ name: "tokenId", type: "uint256" },
|
|
106371
|
-
{ name: "account", type: "address" }
|
|
106372
|
-
],
|
|
106373
|
-
name: "claimable",
|
|
106374
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
106375
|
-
stateMutability: "view",
|
|
106376
|
-
type: "function"
|
|
106377
|
-
}
|
|
106378
|
-
];
|
|
106379
|
-
|
|
106380
|
-
// src/core/services/investment.ts
|
|
106381
|
-
var MAX_UINT256 = 2n ** 256n - 1n;
|
|
106382
|
-
var InvestmentService = class extends EventEmitter {
|
|
106383
|
-
constructor(rpcClient, walletService, networkService) {
|
|
106384
|
-
super();
|
|
106385
|
-
this.rpcClient = rpcClient;
|
|
106386
|
-
this.walletService = walletService;
|
|
106387
|
-
this.networkService = networkService;
|
|
106388
|
-
this.chainIdCache = /* @__PURE__ */ new Map();
|
|
106389
|
-
this.erc20Interface = new import_ethers4.Interface(ERC20_ABI2);
|
|
106390
|
-
this.saleInterface = new import_ethers4.Interface(RBT_PRIMARY_SALE_ROUTER_ABI);
|
|
106391
|
-
this.rbtInterface = new import_ethers4.Interface(RBT_PROPERTY_TOKEN_ABI);
|
|
106392
|
-
}
|
|
106393
|
-
assertHexAddress(addr, field) {
|
|
106394
|
-
const a5 = (addr ?? "").trim();
|
|
106395
|
-
if (!a5.startsWith("0x") || a5.length !== 42) {
|
|
106396
|
-
throw new SDKError(`Invalid ${field}`, "INVALID_PARAMS" /* INVALID_PARAMS */);
|
|
106397
|
-
}
|
|
106398
|
-
}
|
|
106399
|
-
toBigInt(v5, field) {
|
|
106400
|
-
try {
|
|
106401
|
-
if (typeof v5 === "bigint") return v5;
|
|
106402
|
-
if (typeof v5 === "number") {
|
|
106403
|
-
if (!Number.isFinite(v5) || v5 < 0) throw new Error("invalid number");
|
|
106404
|
-
return BigInt(v5);
|
|
106405
|
-
}
|
|
106406
|
-
const s5 = (v5 ?? "").toString().trim();
|
|
106407
|
-
if (!s5) throw new Error("empty");
|
|
106408
|
-
return BigInt(s5);
|
|
106409
|
-
} catch {
|
|
106410
|
-
throw new SDKError(`Invalid ${field}`, "INVALID_PARAMS" /* INVALID_PARAMS */);
|
|
106411
|
-
}
|
|
106412
|
-
}
|
|
106413
|
-
/**
|
|
106414
|
-
* Resolve `networkId` (wallet backend blockchainId UUID) or chainId string -> EVM chainId
|
|
106415
|
-
*/
|
|
106416
|
-
async resolveChainId(networkId) {
|
|
106417
|
-
const trimmed = (networkId ?? "").trim();
|
|
106418
|
-
const cached = this.chainIdCache.get(trimmed);
|
|
106419
|
-
if (cached) return cached;
|
|
106420
|
-
const numeric = Number(trimmed);
|
|
106421
|
-
if (!Number.isNaN(numeric) && Number.isFinite(numeric) && numeric > 0) {
|
|
106422
|
-
this.chainIdCache.set(trimmed, numeric);
|
|
106423
|
-
return numeric;
|
|
106424
|
-
}
|
|
106425
|
-
try {
|
|
106426
|
-
const current = await this.networkService.getCurrentNetwork();
|
|
106427
|
-
if (current && current.id === trimmed) {
|
|
106428
|
-
this.chainIdCache.set(trimmed, current.chainId);
|
|
106429
|
-
return current.chainId;
|
|
106430
|
-
}
|
|
106431
|
-
if (current && String(current.chainId) === trimmed) {
|
|
106432
|
-
this.chainIdCache.set(trimmed, current.chainId);
|
|
106433
|
-
return current.chainId;
|
|
106434
|
-
}
|
|
106435
|
-
} catch {
|
|
106436
|
-
}
|
|
106437
|
-
const networks = await this.networkService.getRegisteredNetworks();
|
|
106438
|
-
const found = networks.find((n5) => n5.id === trimmed);
|
|
106439
|
-
if (found) {
|
|
106440
|
-
this.chainIdCache.set(trimmed, found.chainId);
|
|
106441
|
-
return found.chainId;
|
|
106442
|
-
}
|
|
106443
|
-
const foundByChainId = networks.find((n5) => String(n5.chainId) === trimmed);
|
|
106444
|
-
if (foundByChainId) {
|
|
106445
|
-
this.chainIdCache.set(trimmed, foundByChainId.chainId);
|
|
106446
|
-
return foundByChainId.chainId;
|
|
106447
|
-
}
|
|
106448
|
-
throw new SDKError("Invalid network", "INVALID_NETWORK" /* INVALID_NETWORK */);
|
|
106449
|
-
}
|
|
106450
|
-
async ethCall(chainId, to, data) {
|
|
106451
|
-
const res = await this.rpcClient.sendRpc({
|
|
106452
|
-
chainId,
|
|
106453
|
-
method: "eth_call" /* ETH_CALL */,
|
|
106454
|
-
params: [{ to, data }, "latest"]
|
|
106455
|
-
});
|
|
106456
|
-
if (res.error) {
|
|
106457
|
-
throw new SDKError(
|
|
106458
|
-
`ETH_CALL failed: ${res.error.message}`,
|
|
106459
|
-
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
106460
|
-
res.error
|
|
106461
|
-
);
|
|
106462
|
-
}
|
|
106463
|
-
if (res.result === void 0) {
|
|
106464
|
-
throw new SDKError(
|
|
106465
|
-
"ETH_CALL returned empty result",
|
|
106466
|
-
"REQUEST_FAILED" /* REQUEST_FAILED */
|
|
106467
|
-
);
|
|
106468
|
-
}
|
|
106469
|
-
return res.result;
|
|
106470
|
-
}
|
|
106471
|
-
decodeU256(resultHex, method) {
|
|
106472
|
-
const decoded = this.erc20Interface.decodeFunctionResult(
|
|
106473
|
-
method,
|
|
106474
|
-
resultHex
|
|
106475
|
-
);
|
|
106476
|
-
return BigInt(decoded[0].toString());
|
|
106477
|
-
}
|
|
106478
|
-
async getOffering(params) {
|
|
106479
|
-
this.assertHexAddress(params.saleRouterAddress, "saleRouterAddress");
|
|
106480
|
-
const chainId = await this.resolveChainId(params.networkId);
|
|
106481
|
-
const offeringId = this.toBigInt(params.offeringId, "offeringId");
|
|
106482
|
-
const data = this.saleInterface.encodeFunctionData("offerings", [
|
|
106483
|
-
offeringId
|
|
106484
|
-
]);
|
|
106485
|
-
const result = await this.ethCall(chainId, params.saleRouterAddress, data);
|
|
106486
|
-
const decoded = this.saleInterface.decodeFunctionResult("offerings", result);
|
|
106487
|
-
const asset = decoded[0];
|
|
106488
|
-
const seriesId = BigInt(decoded[1].toString());
|
|
106489
|
-
const unitPrice = BigInt(decoded[2].toString());
|
|
106490
|
-
const remainingUnits = BigInt(decoded[3].toString());
|
|
106491
|
-
const startAt = BigInt(decoded[4].toString());
|
|
106492
|
-
const endAt = BigInt(decoded[5].toString());
|
|
106493
|
-
const treasury = decoded[6];
|
|
106494
|
-
const enabled = Boolean(decoded[7]);
|
|
106495
|
-
return {
|
|
106496
|
-
asset,
|
|
106497
|
-
seriesId,
|
|
106498
|
-
unitPrice,
|
|
106499
|
-
remainingUnits,
|
|
106500
|
-
startAt,
|
|
106501
|
-
endAt,
|
|
106502
|
-
treasury,
|
|
106503
|
-
enabled
|
|
106504
|
-
};
|
|
106505
|
-
}
|
|
106506
|
-
/**
|
|
106507
|
-
* USDR로 투자 (approve 필요. autoApprove 옵션 제공)
|
|
106508
|
-
* - Router.buy(offeringId, units, maxCost) 호출
|
|
106509
|
-
*/
|
|
106510
|
-
async investRbtWithUsdr(params) {
|
|
106511
|
-
this.assertHexAddress(params.usdrAddress, "usdrAddress");
|
|
106512
|
-
this.assertHexAddress(params.saleRouterAddress, "saleRouterAddress");
|
|
106513
|
-
const chainId = await this.resolveChainId(params.networkId);
|
|
106514
|
-
const offeringId = this.toBigInt(params.offeringId, "offeringId");
|
|
106515
|
-
const units = this.toBigInt(params.units, "units");
|
|
106516
|
-
if (units <= 0n) {
|
|
106517
|
-
throw new SDKError("Invalid units", "INVALID_PARAMS" /* INVALID_PARAMS */);
|
|
106518
|
-
}
|
|
106519
|
-
const offering = await this.getOffering({
|
|
106520
|
-
networkId: params.networkId,
|
|
106521
|
-
saleRouterAddress: params.saleRouterAddress,
|
|
106522
|
-
offeringId
|
|
106523
|
-
});
|
|
106524
|
-
if (!offering.enabled) {
|
|
106525
|
-
throw new SDKError("Offering is disabled", "REQUEST_FAILED" /* REQUEST_FAILED */);
|
|
106526
|
-
}
|
|
106527
|
-
const cost = units * offering.unitPrice;
|
|
106528
|
-
const maxCost = params.maxCostWei != null ? this.toBigInt(params.maxCostWei, "maxCostWei") : cost;
|
|
106529
|
-
if (maxCost < cost) {
|
|
106530
|
-
throw new SDKError(
|
|
106531
|
-
"maxCostWei is less than required cost",
|
|
106532
|
-
"INVALID_PARAMS" /* INVALID_PARAMS */
|
|
106533
|
-
);
|
|
106534
|
-
}
|
|
106535
|
-
const buyer = await this.walletService.getAddress();
|
|
106536
|
-
let approvalTxHash;
|
|
106537
|
-
const autoApprove = params.autoApprove ?? true;
|
|
106538
|
-
const approveMax = params.approveMax ?? true;
|
|
106539
|
-
const waitForApprovalReceipt = params.waitForApprovalReceipt ?? true;
|
|
106540
|
-
if (autoApprove) {
|
|
106541
|
-
const allowanceData = this.erc20Interface.encodeFunctionData(
|
|
106542
|
-
"allowance",
|
|
106543
|
-
[buyer, params.saleRouterAddress]
|
|
106544
|
-
);
|
|
106545
|
-
const allowanceHex = await this.ethCall(
|
|
106546
|
-
chainId,
|
|
106547
|
-
params.usdrAddress,
|
|
106548
|
-
allowanceData
|
|
106549
|
-
);
|
|
106550
|
-
const allowanceDecoded = this.erc20Interface.decodeFunctionResult(
|
|
106551
|
-
"allowance",
|
|
106552
|
-
allowanceHex
|
|
106553
|
-
);
|
|
106554
|
-
const allowance = BigInt(allowanceDecoded[0].toString());
|
|
106555
|
-
if (allowance < cost) {
|
|
106556
|
-
const approveAmount = approveMax ? MAX_UINT256 : cost;
|
|
106557
|
-
const approveData = this.erc20Interface.encodeFunctionData("approve", [
|
|
106558
|
-
params.saleRouterAddress,
|
|
106559
|
-
approveAmount.toString()
|
|
106560
|
-
]);
|
|
106561
|
-
approvalTxHash = await this.walletService.sendTransaction({
|
|
106562
|
-
to: params.usdrAddress,
|
|
106563
|
-
value: "0",
|
|
106564
|
-
data: approveData,
|
|
106565
|
-
chainId,
|
|
106566
|
-
gasLimit: params.gasLimitApprove
|
|
106567
|
-
});
|
|
106568
|
-
this.trackTransaction(approvalTxHash, chainId);
|
|
106569
|
-
if (waitForApprovalReceipt) {
|
|
106570
|
-
const ok = await this.waitForSuccessReceipt(approvalTxHash, chainId);
|
|
106571
|
-
if (!ok) {
|
|
106572
|
-
throw new SDKError(
|
|
106573
|
-
"Approve transaction failed",
|
|
106574
|
-
"TRANSACTION_FAILED" /* TRANSACTION_FAILED */
|
|
106575
|
-
);
|
|
106576
|
-
}
|
|
106577
|
-
}
|
|
106578
|
-
}
|
|
106579
|
-
}
|
|
106580
|
-
const buyData = this.saleInterface.encodeFunctionData("buy", [
|
|
106581
|
-
offeringId,
|
|
106582
|
-
units,
|
|
106583
|
-
maxCost
|
|
106584
|
-
]);
|
|
106585
|
-
const purchaseTxHash = await this.walletService.sendTransaction({
|
|
106586
|
-
to: params.saleRouterAddress,
|
|
106587
|
-
value: "0",
|
|
106588
|
-
data: buyData,
|
|
106589
|
-
chainId,
|
|
106590
|
-
gasLimit: params.gasLimitBuy
|
|
106591
|
-
});
|
|
106592
|
-
this.trackTransaction(purchaseTxHash, chainId);
|
|
106593
|
-
return {
|
|
106594
|
-
offering,
|
|
106595
|
-
costWei: cost.toString(),
|
|
106596
|
-
approvalTxHash,
|
|
106597
|
-
purchaseTxHash
|
|
106598
|
-
};
|
|
106599
|
-
}
|
|
106600
|
-
/**
|
|
106601
|
-
* RBT 수익(이자) claim
|
|
106602
|
-
* - RBTPropertyToken.claim(seriesId)
|
|
106603
|
-
*/
|
|
106604
|
-
async claimRbtRevenue(params) {
|
|
106605
|
-
this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
|
|
106606
|
-
const chainId = await this.resolveChainId(params.networkId);
|
|
106607
|
-
const seriesId = this.toBigInt(params.seriesId, "seriesId");
|
|
106608
|
-
const claimData = this.rbtInterface.encodeFunctionData("claim", [seriesId]);
|
|
106609
|
-
const txHash = await this.walletService.sendTransaction({
|
|
106610
|
-
to: params.rbtAssetAddress,
|
|
106611
|
-
value: "0",
|
|
106612
|
-
data: claimData,
|
|
106613
|
-
chainId,
|
|
106614
|
-
gasLimit: params.gasLimit
|
|
106615
|
-
});
|
|
106616
|
-
this.trackTransaction(txHash, chainId);
|
|
106617
|
-
return { txHash };
|
|
106618
|
-
}
|
|
106619
|
-
/**
|
|
106620
|
-
* claimable 조회 (eth_call)
|
|
106621
|
-
*/
|
|
106622
|
-
async getClaimable(params) {
|
|
106623
|
-
this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
|
|
106624
|
-
const chainId = await this.resolveChainId(params.networkId);
|
|
106625
|
-
const seriesId = this.toBigInt(params.seriesId, "seriesId");
|
|
106626
|
-
const account = params.account ?? await this.walletService.getAddress();
|
|
106627
|
-
this.assertHexAddress(account, "account");
|
|
106628
|
-
const data = this.rbtInterface.encodeFunctionData("claimable", [
|
|
106629
|
-
seriesId,
|
|
106630
|
-
account
|
|
106631
|
-
]);
|
|
106632
|
-
const result = await this.ethCall(chainId, params.rbtAssetAddress, data);
|
|
106633
|
-
const decoded = this.rbtInterface.decodeFunctionResult("claimable", result);
|
|
106634
|
-
return BigInt(decoded[0].toString()).toString();
|
|
106635
|
-
}
|
|
106636
|
-
/**
|
|
106637
|
-
* RBT balanceOf 조회 (eth_call)
|
|
106638
|
-
*/
|
|
106639
|
-
async getRbtBalance(params) {
|
|
106640
|
-
this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
|
|
106641
|
-
const chainId = await this.resolveChainId(params.networkId);
|
|
106642
|
-
const seriesId = this.toBigInt(params.seriesId, "seriesId");
|
|
106643
|
-
const account = params.account ?? await this.walletService.getAddress();
|
|
106644
|
-
this.assertHexAddress(account, "account");
|
|
106645
|
-
const data = this.rbtInterface.encodeFunctionData("balanceOf", [
|
|
106646
|
-
account,
|
|
106647
|
-
seriesId
|
|
106648
|
-
]);
|
|
106649
|
-
const result = await this.ethCall(chainId, params.rbtAssetAddress, data);
|
|
106650
|
-
const decoded = this.rbtInterface.decodeFunctionResult("balanceOf", result);
|
|
106651
|
-
return BigInt(decoded[0].toString()).toString();
|
|
106652
|
-
}
|
|
106653
|
-
async waitForSuccessReceipt(txHash, chainId) {
|
|
106654
|
-
let retryCount = 0;
|
|
106655
|
-
const MAX_RETRIES = 20;
|
|
106656
|
-
while (retryCount < MAX_RETRIES) {
|
|
106657
|
-
const res = await this.rpcClient.sendRpc({
|
|
106658
|
-
chainId,
|
|
106659
|
-
method: "eth_getTransactionReceipt" /* ETH_GET_TRANSACTION_RECEIPT */,
|
|
106660
|
-
params: [txHash]
|
|
106661
|
-
});
|
|
106662
|
-
if (res.result) {
|
|
106663
|
-
return res.result.status === "0x1";
|
|
106664
|
-
}
|
|
106665
|
-
retryCount++;
|
|
106666
|
-
await new Promise((r5) => setTimeout$1(r5, 3e3));
|
|
106667
|
-
}
|
|
106668
|
-
return false;
|
|
106669
|
-
}
|
|
106670
|
-
trackTransaction(txHash, chainId) {
|
|
106671
|
-
let retryCount = 0;
|
|
106672
|
-
const MAX_RETRIES = 20;
|
|
106673
|
-
const checkStatus = async () => {
|
|
106674
|
-
try {
|
|
106675
|
-
const response = await this.rpcClient.sendRpc({
|
|
106676
|
-
chainId,
|
|
106677
|
-
method: "eth_getTransactionReceipt" /* ETH_GET_TRANSACTION_RECEIPT */,
|
|
106678
|
-
params: [txHash]
|
|
106679
|
-
});
|
|
106680
|
-
if (response.result) {
|
|
106681
|
-
const status = response.result.status === "0x1" ? "SUCCESS" /* SUCCESS */ : "FAILED" /* FAILED */;
|
|
106682
|
-
this.emit("transactionStatusChanged", {
|
|
106683
|
-
hash: txHash,
|
|
106684
|
-
status,
|
|
106685
|
-
timestamp: Date.now()
|
|
106686
|
-
});
|
|
106687
|
-
return;
|
|
106688
|
-
}
|
|
106689
|
-
retryCount++;
|
|
106690
|
-
if (retryCount < MAX_RETRIES) {
|
|
106691
|
-
setTimeout$1(checkStatus, 3e3);
|
|
106692
|
-
} else {
|
|
106693
|
-
this.emit("transactionStatusChanged", {
|
|
106694
|
-
hash: txHash,
|
|
106695
|
-
status: "FAILED" /* FAILED */,
|
|
106696
|
-
timestamp: Date.now(),
|
|
106697
|
-
error: "Transaction timeout"
|
|
106698
|
-
});
|
|
106699
|
-
}
|
|
106700
|
-
} catch (error) {
|
|
106701
|
-
this.emit("transactionStatusChanged", {
|
|
106702
|
-
hash: txHash,
|
|
106703
|
-
status: "FAILED" /* FAILED */,
|
|
106704
|
-
timestamp: Date.now(),
|
|
106705
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
106706
|
-
});
|
|
106707
|
-
}
|
|
106708
|
-
};
|
|
106709
|
-
checkStatus();
|
|
106710
|
-
}
|
|
106711
|
-
};
|
|
106712
|
-
|
|
106713
106451
|
// src/core/internal.ts
|
|
106714
106452
|
var InternalCoreImpl = class {
|
|
106715
106453
|
constructor(options) {
|
|
@@ -106749,9 +106487,22 @@ var InternalCoreImpl = class {
|
|
|
106749
106487
|
addToken: (params) => this.assetService.addToken(params),
|
|
106750
106488
|
// New ERC20 methods
|
|
106751
106489
|
getTokenBalance: (params) => this.assetService.getTokenBalance(params),
|
|
106490
|
+
// ERC1155 / RBT helpers
|
|
106491
|
+
getERC1155Balance: (params) => this.assetService.getERC1155Balance(params),
|
|
106492
|
+
getRbtClaimable: (params) => this.assetService.getRbtClaimable(params),
|
|
106493
|
+
claimRbt: (params) => this.assetService.claimRbt(params),
|
|
106752
106494
|
approveToken: (params) => this.assetService.approveToken(params),
|
|
106753
106495
|
getAllowance: (params) => this.assetService.getAllowance(params),
|
|
106496
|
+
// getTokenInfo: (params: TokenInfoParams) =>
|
|
106497
|
+
// this.assetService.getTokenInfo(params),
|
|
106754
106498
|
addNFTCollection: (params) => this.assetService.addNFTCollection(params),
|
|
106499
|
+
// checkSecurityTokenCompliance: (params: {
|
|
106500
|
+
// networkId: string
|
|
106501
|
+
// tokenAddress: string
|
|
106502
|
+
// from: string
|
|
106503
|
+
// to: string
|
|
106504
|
+
// amount: string
|
|
106505
|
+
// }) => this.assetService.checkSecurityTokenCompliance(params),
|
|
106755
106506
|
on: (event, listener) => this.assetService.on(event, listener),
|
|
106756
106507
|
off: (event, listener) => this.assetService.off(event, listener),
|
|
106757
106508
|
getTokenInfo: (params) => this.assetService.getTokenInfo(params),
|
|
@@ -106759,15 +106510,6 @@ var InternalCoreImpl = class {
|
|
|
106759
106510
|
getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params),
|
|
106760
106511
|
getRegisteredCoins: (networkId) => this.assetService.getRegisteredCoins(networkId)
|
|
106761
106512
|
};
|
|
106762
|
-
this.investment = {
|
|
106763
|
-
getOffering: (params) => this.investmentService.getOffering(params),
|
|
106764
|
-
investRbtWithUsdr: (params) => this.investmentService.investRbtWithUsdr(params),
|
|
106765
|
-
claimRbtRevenue: (params) => this.investmentService.claimRbtRevenue(params),
|
|
106766
|
-
getClaimable: (params) => this.investmentService.getClaimable(params),
|
|
106767
|
-
getRbtBalance: (params) => this.investmentService.getRbtBalance(params),
|
|
106768
|
-
on: (event, listener) => this.investmentService.on(event, listener),
|
|
106769
|
-
off: (event, listener) => this.investmentService.off(event, listener)
|
|
106770
|
-
};
|
|
106771
106513
|
const httpClient = new HttpClient(options);
|
|
106772
106514
|
const firebase = new FirebaseAuth(options);
|
|
106773
106515
|
const userClient = new UserClient(httpClient);
|
|
@@ -106793,11 +106535,6 @@ var InternalCoreImpl = class {
|
|
|
106793
106535
|
userClient,
|
|
106794
106536
|
options.orgHost
|
|
106795
106537
|
);
|
|
106796
|
-
this.investmentService = new InvestmentService(
|
|
106797
|
-
rpcClient,
|
|
106798
|
-
this.walletService,
|
|
106799
|
-
this.networkService
|
|
106800
|
-
);
|
|
106801
106538
|
}
|
|
106802
106539
|
};
|
|
106803
106540
|
|
|
@@ -107050,6 +106787,15 @@ var AssetModule = class {
|
|
|
107050
106787
|
async getTokenBalance(params) {
|
|
107051
106788
|
return this.core.asset.getTokenBalance(params);
|
|
107052
106789
|
}
|
|
106790
|
+
async getERC1155Balance(params) {
|
|
106791
|
+
return this.core.asset.getERC1155Balance(params);
|
|
106792
|
+
}
|
|
106793
|
+
async getRbtClaimable(params) {
|
|
106794
|
+
return this.core.asset.getRbtClaimable(params);
|
|
106795
|
+
}
|
|
106796
|
+
async claimRbt(params) {
|
|
106797
|
+
return this.core.asset.claimRbt(params);
|
|
106798
|
+
}
|
|
107053
106799
|
async approveToken(params) {
|
|
107054
106800
|
return this.core.asset.approveToken(params);
|
|
107055
106801
|
}
|
|
@@ -107073,35 +106819,6 @@ var AssetModule = class {
|
|
|
107073
106819
|
}
|
|
107074
106820
|
};
|
|
107075
106821
|
|
|
107076
|
-
// src/modules/Investment.ts
|
|
107077
|
-
var InvestmentModule = class {
|
|
107078
|
-
constructor(options, core) {
|
|
107079
|
-
this.options = options;
|
|
107080
|
-
this.core = core;
|
|
107081
|
-
}
|
|
107082
|
-
getOffering(params) {
|
|
107083
|
-
return this.core.investment.getOffering(params);
|
|
107084
|
-
}
|
|
107085
|
-
investRbtWithUsdr(params) {
|
|
107086
|
-
return this.core.investment.investRbtWithUsdr(params);
|
|
107087
|
-
}
|
|
107088
|
-
claimRbtRevenue(params) {
|
|
107089
|
-
return this.core.investment.claimRbtRevenue(params);
|
|
107090
|
-
}
|
|
107091
|
-
getClaimable(params) {
|
|
107092
|
-
return this.core.investment.getClaimable(params);
|
|
107093
|
-
}
|
|
107094
|
-
getRbtBalance(params) {
|
|
107095
|
-
return this.core.investment.getRbtBalance(params);
|
|
107096
|
-
}
|
|
107097
|
-
on(event, listener) {
|
|
107098
|
-
this.core.investment.on(event, listener);
|
|
107099
|
-
}
|
|
107100
|
-
off(event, listener) {
|
|
107101
|
-
this.core.investment.off(event, listener);
|
|
107102
|
-
}
|
|
107103
|
-
};
|
|
107104
|
-
|
|
107105
106822
|
// src/utils/network.ts
|
|
107106
106823
|
var KNOWN_NETWORKS = {
|
|
107107
106824
|
1: {
|
|
@@ -107169,134 +106886,88 @@ var WeBlockSDK = class {
|
|
|
107169
106886
|
this.initialized = false;
|
|
107170
106887
|
this.user = {
|
|
107171
106888
|
signIn: async (provider) => {
|
|
107172
|
-
this.ensureInitialized();
|
|
107173
106889
|
return this.userModule.signIn(provider);
|
|
107174
106890
|
},
|
|
107175
106891
|
createWallet: async (password) => {
|
|
107176
|
-
this.ensureInitialized();
|
|
107177
106892
|
return this.userModule.createWallet(password);
|
|
107178
106893
|
},
|
|
107179
106894
|
retrieveWallet: async (password) => {
|
|
107180
|
-
this.ensureInitialized();
|
|
107181
106895
|
return this.userModule.retrieveWallet(password);
|
|
107182
106896
|
},
|
|
107183
106897
|
/**
|
|
107184
106898
|
* ✅ 추가: PIN reset API 노출
|
|
107185
106899
|
*/
|
|
107186
106900
|
resetPin: async (newPassword) => {
|
|
107187
|
-
this.ensureInitialized();
|
|
107188
106901
|
return this.userModule.resetPin(newPassword);
|
|
107189
106902
|
},
|
|
107190
106903
|
signOut: async () => {
|
|
107191
|
-
this.ensureInitialized();
|
|
107192
106904
|
return this.userModule.signOut();
|
|
107193
106905
|
}
|
|
107194
106906
|
};
|
|
107195
106907
|
this.wallet = {
|
|
107196
106908
|
getInfo: async () => {
|
|
107197
|
-
this.ensureInitialized();
|
|
107198
106909
|
return this.walletModule.getInfo();
|
|
107199
106910
|
},
|
|
107200
106911
|
onWalletUpdate: (callback) => {
|
|
107201
|
-
this.ensureInitialized();
|
|
107202
106912
|
return this.walletModule.onWalletUpdate(callback);
|
|
107203
106913
|
},
|
|
107204
106914
|
onTransactionUpdate: (callback) => {
|
|
107205
|
-
this.ensureInitialized();
|
|
107206
106915
|
return this.walletModule.onTransactionUpdate(callback);
|
|
107207
106916
|
},
|
|
107208
106917
|
getBalance: (address, chainId) => {
|
|
107209
|
-
this.ensureInitialized();
|
|
107210
106918
|
return this.walletModule.getBalance(address, chainId);
|
|
107211
106919
|
},
|
|
107212
106920
|
getTransactionCount: (address, chainId) => {
|
|
107213
|
-
this.ensureInitialized();
|
|
107214
106921
|
return this.walletModule.getTransactionCount(address, chainId);
|
|
107215
106922
|
},
|
|
107216
106923
|
getBlockNumber: (chainId) => {
|
|
107217
|
-
this.ensureInitialized();
|
|
107218
106924
|
return this.walletModule.getBlockNumber(chainId);
|
|
107219
106925
|
},
|
|
107220
106926
|
sendRawTransaction: (signedTx, chainId) => {
|
|
107221
|
-
this.ensureInitialized();
|
|
107222
106927
|
return this.walletModule.sendRawTransaction(signedTx, chainId);
|
|
107223
106928
|
},
|
|
107224
106929
|
getTransactionReceipt: (txHash, chainId) => {
|
|
107225
|
-
this.ensureInitialized();
|
|
107226
106930
|
return this.walletModule.getTransactionReceipt(txHash, chainId);
|
|
107227
106931
|
},
|
|
107228
106932
|
getTransaction: (txHash, chainId) => {
|
|
107229
|
-
this.ensureInitialized();
|
|
107230
106933
|
return this.walletModule.getTransaction(txHash, chainId);
|
|
107231
106934
|
},
|
|
107232
106935
|
estimateGas: (txParams, chainId) => {
|
|
107233
|
-
this.ensureInitialized();
|
|
107234
106936
|
return this.walletModule.estimateGas(txParams, chainId);
|
|
107235
106937
|
},
|
|
107236
106938
|
getGasPrice: (chainId) => {
|
|
107237
|
-
this.ensureInitialized();
|
|
107238
106939
|
return this.walletModule.getGasPrice(chainId);
|
|
107239
106940
|
},
|
|
107240
106941
|
call: (txParams, blockParam, chainId) => {
|
|
107241
|
-
this.ensureInitialized();
|
|
107242
106942
|
return this.walletModule.call(txParams, blockParam, chainId);
|
|
107243
106943
|
}
|
|
107244
106944
|
};
|
|
107245
106945
|
this.network = {
|
|
107246
|
-
getAvailableNetworks: () =>
|
|
107247
|
-
|
|
107248
|
-
|
|
107249
|
-
|
|
107250
|
-
addNetwork: (request) => {
|
|
107251
|
-
this.ensureInitialized();
|
|
107252
|
-
return this.networkModule.addNetwork(request);
|
|
107253
|
-
},
|
|
107254
|
-
switchNetwork: (networkId) => {
|
|
107255
|
-
this.ensureInitialized();
|
|
107256
|
-
return this.networkModule.switchNetwork(networkId);
|
|
107257
|
-
},
|
|
107258
|
-
getCurrentNetwork: () => {
|
|
107259
|
-
this.ensureInitialized();
|
|
107260
|
-
return this.networkModule.getCurrentNetwork();
|
|
107261
|
-
}
|
|
106946
|
+
getAvailableNetworks: () => this.networkModule.getAvailableNetworks(),
|
|
106947
|
+
addNetwork: (request) => this.networkModule.addNetwork(request),
|
|
106948
|
+
switchNetwork: (networkId) => this.networkModule.switchNetwork(networkId),
|
|
106949
|
+
getCurrentNetwork: () => this.networkModule.getCurrentNetwork()
|
|
107262
106950
|
};
|
|
107263
106951
|
this.asset = {
|
|
107264
106952
|
transfer: async (params) => {
|
|
107265
|
-
this.ensureInitialized();
|
|
107266
106953
|
return this.assetModule.transfer(params);
|
|
107267
106954
|
},
|
|
107268
106955
|
addToken: async (params) => {
|
|
107269
|
-
this.ensureInitialized();
|
|
107270
106956
|
return this.assetModule.addToken(params);
|
|
107271
106957
|
},
|
|
107272
106958
|
addNFTCollection: async (params) => {
|
|
107273
|
-
this.ensureInitialized();
|
|
107274
106959
|
return this.assetModule.addNFTCollection(params);
|
|
107275
106960
|
},
|
|
107276
106961
|
on: (event, listener) => {
|
|
107277
|
-
this.ensureInitialized();
|
|
107278
106962
|
this.assetModule.on(event, listener);
|
|
107279
106963
|
},
|
|
107280
106964
|
off: (event, listener) => {
|
|
107281
|
-
this.ensureInitialized();
|
|
107282
106965
|
this.assetModule.off(event, listener);
|
|
107283
106966
|
},
|
|
107284
106967
|
getTokenInfo: async (params) => {
|
|
107285
|
-
this.ensureInitialized();
|
|
107286
106968
|
return this.assetModule.getTokenInfo(params);
|
|
107287
106969
|
},
|
|
107288
|
-
|
|
107289
|
-
this.ensureInitialized();
|
|
107290
|
-
return this.assetModule.registerToken(params);
|
|
107291
|
-
},
|
|
107292
|
-
getTokenFullInfo: async (params) => {
|
|
107293
|
-
this.ensureInitialized();
|
|
107294
|
-
return this.assetModule.getTokenFullInfo(params);
|
|
107295
|
-
},
|
|
107296
|
-
/**
|
|
107297
|
-
* ✅ ERC20 잔액 조회 (주의: 현재 AssetModule 구현은 raw balance string을 반환)
|
|
107298
|
-
* - TokenBalance(객체)가 아니라 string(wei) 입니다.
|
|
107299
|
-
*/
|
|
106970
|
+
// ERC20 helpers
|
|
107300
106971
|
getTokenBalance: async (params) => {
|
|
107301
106972
|
this.ensureInitialized();
|
|
107302
106973
|
return this.assetModule.getTokenBalance(params);
|
|
@@ -107308,39 +106979,25 @@ var WeBlockSDK = class {
|
|
|
107308
106979
|
getAllowance: async (params) => {
|
|
107309
106980
|
this.ensureInitialized();
|
|
107310
106981
|
return this.assetModule.getAllowance(params);
|
|
107311
|
-
}
|
|
107312
|
-
};
|
|
107313
|
-
/**
|
|
107314
|
-
* ✅ NEW: Investment API Surface
|
|
107315
|
-
*/
|
|
107316
|
-
this.invest = {
|
|
107317
|
-
getOffering: async (params) => {
|
|
107318
|
-
this.ensureInitialized();
|
|
107319
|
-
return this.investmentModule.getOffering(params);
|
|
107320
106982
|
},
|
|
107321
|
-
|
|
106983
|
+
// ERC1155 / RBT helpers
|
|
106984
|
+
getERC1155Balance: async (params) => {
|
|
107322
106985
|
this.ensureInitialized();
|
|
107323
|
-
return this.
|
|
106986
|
+
return this.assetModule.getERC1155Balance(params);
|
|
107324
106987
|
},
|
|
107325
|
-
|
|
106988
|
+
getRbtClaimable: async (params) => {
|
|
107326
106989
|
this.ensureInitialized();
|
|
107327
|
-
return this.
|
|
106990
|
+
return this.assetModule.getRbtClaimable(params);
|
|
107328
106991
|
},
|
|
107329
|
-
|
|
106992
|
+
claimRbt: async (params) => {
|
|
107330
106993
|
this.ensureInitialized();
|
|
107331
|
-
return this.
|
|
106994
|
+
return this.assetModule.claimRbt(params);
|
|
107332
106995
|
},
|
|
107333
|
-
|
|
107334
|
-
this.
|
|
107335
|
-
return this.investmentModule.getRbtBalance(params);
|
|
107336
|
-
},
|
|
107337
|
-
on: (event, listener) => {
|
|
107338
|
-
this.ensureInitialized();
|
|
107339
|
-
this.investmentModule.on(event, listener);
|
|
106996
|
+
registerToken: async (params) => {
|
|
106997
|
+
return this.assetModule.registerToken(params);
|
|
107340
106998
|
},
|
|
107341
|
-
|
|
107342
|
-
this.
|
|
107343
|
-
this.investmentModule.off(event, listener);
|
|
106999
|
+
getTokenFullInfo: async (params) => {
|
|
107000
|
+
return this.assetModule.getTokenFullInfo(params);
|
|
107344
107001
|
}
|
|
107345
107002
|
};
|
|
107346
107003
|
this.validateOptions(options);
|
|
@@ -107350,7 +107007,6 @@ var WeBlockSDK = class {
|
|
|
107350
107007
|
this.userModule = new UserModule(options, internalCore, this.walletModule);
|
|
107351
107008
|
this.assetModule = new AssetModule(options, internalCore);
|
|
107352
107009
|
this.networkModule = new NetworkModule(options, internalCore);
|
|
107353
|
-
this.investmentModule = new InvestmentModule(options, internalCore);
|
|
107354
107010
|
this.initialized = true;
|
|
107355
107011
|
console.info("WeBlock SDK initialized successfully");
|
|
107356
107012
|
}
|
|
@@ -107359,15 +107015,13 @@ var WeBlockSDK = class {
|
|
|
107359
107015
|
if (!["local", "dev", "stage", "prod"].includes(environment)) {
|
|
107360
107016
|
throw new SDKError("Invalid environment", "INVALID_CONFIG" /* INVALID_CONFIG */);
|
|
107361
107017
|
}
|
|
107362
|
-
if (!apiKey)
|
|
107018
|
+
if (!apiKey)
|
|
107363
107019
|
throw new SDKError("API key is required", "INVALID_CONFIG" /* INVALID_CONFIG */);
|
|
107364
|
-
|
|
107365
|
-
if (!orgHost) {
|
|
107020
|
+
if (!orgHost)
|
|
107366
107021
|
throw new SDKError(
|
|
107367
107022
|
"Organization host is required",
|
|
107368
107023
|
"INVALID_CONFIG" /* INVALID_CONFIG */
|
|
107369
107024
|
);
|
|
107370
|
-
}
|
|
107371
107025
|
}
|
|
107372
107026
|
ensureInitialized() {
|
|
107373
107027
|
if (!this.initialized) {
|