@weblock-wallet/sdk 0.1.52 → 0.1.53

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.js CHANGED
@@ -105195,6 +105195,44 @@ var ERC20_ABI2 = [
105195
105195
  type: "function"
105196
105196
  }
105197
105197
  ];
105198
+ var ERC1155_ABI = [
105199
+ {
105200
+ constant: true,
105201
+ inputs: [
105202
+ { name: "account", type: "address" },
105203
+ { name: "id", type: "uint256" }
105204
+ ],
105205
+ name: "balanceOf",
105206
+ outputs: [{ name: "", type: "uint256" }],
105207
+ payable: false,
105208
+ stateMutability: "view",
105209
+ type: "function"
105210
+ }
105211
+ ];
105212
+ var RBT_PROPERTY_TOKEN_ABI = [
105213
+ ...ERC1155_ABI,
105214
+ {
105215
+ constant: true,
105216
+ inputs: [
105217
+ { name: "tokenId", type: "uint256" },
105218
+ { name: "account", type: "address" }
105219
+ ],
105220
+ name: "claimable",
105221
+ outputs: [{ name: "", type: "uint256" }],
105222
+ payable: false,
105223
+ stateMutability: "view",
105224
+ type: "function"
105225
+ },
105226
+ {
105227
+ constant: false,
105228
+ inputs: [{ name: "tokenId", type: "uint256" }],
105229
+ name: "claim",
105230
+ outputs: [],
105231
+ payable: false,
105232
+ stateMutability: "nonpayable",
105233
+ type: "function"
105234
+ }
105235
+ ];
105198
105236
 
105199
105237
  // src/core/services/asset.ts
105200
105238
  import { Interface as Interface2 } from "ethers";
@@ -105879,6 +105917,7 @@ var AssetService = class extends EventEmitter {
105879
105917
  this.orgHost = orgHost;
105880
105918
  this.chainIdCache = /* @__PURE__ */ new Map();
105881
105919
  this.erc20Interface = new Interface2(ERC20_ABI2);
105920
+ this.rbtInterface = new Interface2(RBT_PROPERTY_TOKEN_ABI);
105882
105921
  }
105883
105922
  /**
105884
105923
  * Resolve a user-facing networkId (blockchainId) into an EVM chainId for /v1/rpcs.
@@ -106176,21 +106215,116 @@ var AssetService = class extends EventEmitter {
106176
106215
  );
106177
106216
  }
106178
106217
  }
106179
- async approveToken(params) {
106218
+ /**
106219
+ * ERC-1155 balanceOf(account, tokenId)
106220
+ * - Returns raw hex string (0x...)
106221
+ */
106222
+ async getERC1155Balance(params) {
106180
106223
  try {
106181
106224
  const chainId = await this.resolveChainId(params.networkId);
106182
- const data = this.erc20Interface.encodeFunctionData("approve", [
106183
- params.spender,
106184
- params.amount
106225
+ const data = this.rbtInterface.encodeFunctionData("balanceOf", [
106226
+ params.walletAddress,
106227
+ params.tokenId
106228
+ ]);
106229
+ const response = await this.rpcClient.sendRpc({
106230
+ chainId,
106231
+ method: "eth_call" /* ETH_CALL */,
106232
+ params: [
106233
+ {
106234
+ to: params.tokenAddress,
106235
+ data
106236
+ },
106237
+ "latest"
106238
+ ]
106239
+ });
106240
+ return response.result;
106241
+ } catch (error) {
106242
+ throw new SDKError(
106243
+ "Failed to get ERC1155 balance",
106244
+ "REQUEST_FAILED" /* REQUEST_FAILED */,
106245
+ error
106246
+ );
106247
+ }
106248
+ }
106249
+ /**
106250
+ * RBTPropertyToken claimable(tokenId, account)
106251
+ * - Returns raw hex string (0x...)
106252
+ */
106253
+ async getRbtClaimable(params) {
106254
+ try {
106255
+ const chainId = await this.resolveChainId(params.networkId);
106256
+ const data = this.rbtInterface.encodeFunctionData("claimable", [
106257
+ params.tokenId,
106258
+ params.walletAddress
106259
+ ]);
106260
+ const response = await this.rpcClient.sendRpc({
106261
+ chainId,
106262
+ method: "eth_call" /* ETH_CALL */,
106263
+ params: [
106264
+ {
106265
+ to: params.tokenAddress,
106266
+ data
106267
+ },
106268
+ "latest"
106269
+ ]
106270
+ });
106271
+ return response.result;
106272
+ } catch (error) {
106273
+ throw new SDKError(
106274
+ "Failed to get claimable amount",
106275
+ "REQUEST_FAILED" /* REQUEST_FAILED */,
106276
+ error
106277
+ );
106278
+ }
106279
+ }
106280
+ /**
106281
+ * RBTPropertyToken claim(tokenId)
106282
+ * - Sends a signed transaction via WalletService
106283
+ * - Returns txHash
106284
+ */
106285
+ async claimRbt(params) {
106286
+ try {
106287
+ const chainId = await this.resolveChainId(params.networkId);
106288
+ const data = this.rbtInterface.encodeFunctionData("claim", [
106289
+ params.tokenId
106185
106290
  ]);
106186
106291
  const txHash = await this.walletService.sendTransaction({
106187
106292
  to: params.tokenAddress,
106188
106293
  value: "0",
106189
106294
  data,
106190
- chainId
106295
+ chainId,
106296
+ gasLimit: params.gasLimit,
106297
+ gasPrice: params.gasPrice,
106298
+ nonce: params.nonce
106191
106299
  });
106192
106300
  this.trackTransaction(txHash, chainId);
106193
106301
  return txHash;
106302
+ } catch (error) {
106303
+ throw new SDKError(
106304
+ "Failed to claim RBT",
106305
+ "REQUEST_FAILED" /* REQUEST_FAILED */,
106306
+ error
106307
+ );
106308
+ }
106309
+ }
106310
+ async approveToken(params) {
106311
+ try {
106312
+ const chainId = await this.resolveChainId(params.networkId);
106313
+ const data = this.erc20Interface.encodeFunctionData("approve", [
106314
+ params.spender,
106315
+ params.amount
106316
+ ]);
106317
+ const response = await this.rpcClient.sendRpc({
106318
+ chainId,
106319
+ method: "eth_sendRawTransaction" /* ETH_SEND_RAW_TRANSACTION */,
106320
+ params: [
106321
+ {
106322
+ to: params.tokenAddress,
106323
+ data
106324
+ }
106325
+ ]
106326
+ });
106327
+ return response.result;
106194
106328
  } catch (error) {
106195
106329
  throw new SDKError(
106196
106330
  "Failed to approve token",
@@ -106273,402 +106407,6 @@ var AssetService = class extends EventEmitter {
106273
106407
  // }
106274
106408
  };
106275
106409
 
106276
- // src/core/services/investment.ts
106277
- import { Interface as Interface3 } from "ethers";
106278
-
106279
- // src/contract/weblock.ts
106280
- var RBT_PRIMARY_SALE_ROUTER_ABI = [
106281
- {
106282
- inputs: [{ name: "offeringId", type: "uint256" }],
106283
- name: "offerings",
106284
- outputs: [
106285
- { name: "asset", type: "address" },
106286
- { name: "seriesId", type: "uint256" },
106287
- { name: "unitPrice", type: "uint256" },
106288
- { name: "remainingUnits", type: "uint256" },
106289
- { name: "startAt", type: "uint64" },
106290
- { name: "endAt", type: "uint64" },
106291
- { name: "treasury", type: "address" },
106292
- { name: "enabled", type: "bool" }
106293
- ],
106294
- stateMutability: "view",
106295
- type: "function"
106296
- },
106297
- {
106298
- inputs: [
106299
- { name: "offeringId", type: "uint256" },
106300
- { name: "units", type: "uint256" },
106301
- { name: "maxCost", type: "uint256" }
106302
- ],
106303
- name: "buy",
106304
- outputs: [],
106305
- stateMutability: "nonpayable",
106306
- type: "function"
106307
- }
106308
- ];
106309
- var RBT_PROPERTY_TOKEN_ABI = [
106310
- {
106311
- inputs: [
106312
- { name: "account", type: "address" },
106313
- { name: "id", type: "uint256" }
106314
- ],
106315
- name: "balanceOf",
106316
- outputs: [{ name: "", type: "uint256" }],
106317
- stateMutability: "view",
106318
- type: "function"
106319
- },
106320
- {
106321
- inputs: [{ name: "tokenId", type: "uint256" }],
106322
- name: "claim",
106323
- outputs: [],
106324
- stateMutability: "nonpayable",
106325
- type: "function"
106326
- },
106327
- {
106328
- inputs: [
106329
- { name: "tokenId", type: "uint256" },
106330
- { name: "account", type: "address" }
106331
- ],
106332
- name: "claimable",
106333
- outputs: [{ name: "", type: "uint256" }],
106334
- stateMutability: "view",
106335
- type: "function"
106336
- }
106337
- ];
106338
-
106339
- // src/core/services/investment.ts
106340
- var MAX_UINT256 = 2n ** 256n - 1n;
106341
- var InvestmentService = class extends EventEmitter {
106342
- constructor(rpcClient, walletService, networkService) {
106343
- super();
106344
- this.rpcClient = rpcClient;
106345
- this.walletService = walletService;
106346
- this.networkService = networkService;
106347
- this.chainIdCache = /* @__PURE__ */ new Map();
106348
- this.erc20Interface = new Interface3(ERC20_ABI2);
106349
- this.saleInterface = new Interface3(RBT_PRIMARY_SALE_ROUTER_ABI);
106350
- this.rbtInterface = new Interface3(RBT_PROPERTY_TOKEN_ABI);
106351
- }
106352
- assertHexAddress(addr, field) {
106353
- const a5 = (addr ?? "").trim();
106354
- if (!a5.startsWith("0x") || a5.length !== 42) {
106355
- throw new SDKError(`Invalid ${field}`, "INVALID_PARAMS" /* INVALID_PARAMS */);
106356
- }
106357
- }
106358
- toBigInt(v5, field) {
106359
- try {
106360
- if (typeof v5 === "bigint") return v5;
106361
- if (typeof v5 === "number") {
106362
- if (!Number.isFinite(v5) || v5 < 0) throw new Error("invalid number");
106363
- return BigInt(v5);
106364
- }
106365
- const s5 = (v5 ?? "").toString().trim();
106366
- if (!s5) throw new Error("empty");
106367
- return BigInt(s5);
106368
- } catch {
106369
- throw new SDKError(`Invalid ${field}`, "INVALID_PARAMS" /* INVALID_PARAMS */);
106370
- }
106371
- }
106372
- /**
106373
- * Resolve `networkId` (wallet backend blockchainId UUID) or chainId string -> EVM chainId
106374
- */
106375
- async resolveChainId(networkId) {
106376
- const trimmed = (networkId ?? "").trim();
106377
- const cached = this.chainIdCache.get(trimmed);
106378
- if (cached) return cached;
106379
- const numeric = Number(trimmed);
106380
- if (!Number.isNaN(numeric) && Number.isFinite(numeric) && numeric > 0) {
106381
- this.chainIdCache.set(trimmed, numeric);
106382
- return numeric;
106383
- }
106384
- try {
106385
- const current = await this.networkService.getCurrentNetwork();
106386
- if (current && current.id === trimmed) {
106387
- this.chainIdCache.set(trimmed, current.chainId);
106388
- return current.chainId;
106389
- }
106390
- if (current && String(current.chainId) === trimmed) {
106391
- this.chainIdCache.set(trimmed, current.chainId);
106392
- return current.chainId;
106393
- }
106394
- } catch {
106395
- }
106396
- const networks = await this.networkService.getRegisteredNetworks();
106397
- const found = networks.find((n5) => n5.id === trimmed);
106398
- if (found) {
106399
- this.chainIdCache.set(trimmed, found.chainId);
106400
- return found.chainId;
106401
- }
106402
- const foundByChainId = networks.find((n5) => String(n5.chainId) === trimmed);
106403
- if (foundByChainId) {
106404
- this.chainIdCache.set(trimmed, foundByChainId.chainId);
106405
- return foundByChainId.chainId;
106406
- }
106407
- throw new SDKError("Invalid network", "INVALID_NETWORK" /* INVALID_NETWORK */);
106408
- }
106409
- async ethCall(chainId, to, data) {
106410
- const res = await this.rpcClient.sendRpc({
106411
- chainId,
106412
- method: "eth_call" /* ETH_CALL */,
106413
- params: [{ to, data }, "latest"]
106414
- });
106415
- if (res.error) {
106416
- throw new SDKError(
106417
- `ETH_CALL failed: ${res.error.message}`,
106418
- "REQUEST_FAILED" /* REQUEST_FAILED */,
106419
- res.error
106420
- );
106421
- }
106422
- if (res.result === void 0) {
106423
- throw new SDKError(
106424
- "ETH_CALL returned empty result",
106425
- "REQUEST_FAILED" /* REQUEST_FAILED */
106426
- );
106427
- }
106428
- return res.result;
106429
- }
106430
- decodeU256(resultHex, method) {
106431
- const decoded = this.erc20Interface.decodeFunctionResult(
106432
- method,
106433
- resultHex
106434
- );
106435
- return BigInt(decoded[0].toString());
106436
- }
106437
- async getOffering(params) {
106438
- this.assertHexAddress(params.saleRouterAddress, "saleRouterAddress");
106439
- const chainId = await this.resolveChainId(params.networkId);
106440
- const offeringId = this.toBigInt(params.offeringId, "offeringId");
106441
- const data = this.saleInterface.encodeFunctionData("offerings", [
106442
- offeringId
106443
- ]);
106444
- const result = await this.ethCall(chainId, params.saleRouterAddress, data);
106445
- const decoded = this.saleInterface.decodeFunctionResult("offerings", result);
106446
- const asset = decoded[0];
106447
- const seriesId = BigInt(decoded[1].toString());
106448
- const unitPrice = BigInt(decoded[2].toString());
106449
- const remainingUnits = BigInt(decoded[3].toString());
106450
- const startAt = BigInt(decoded[4].toString());
106451
- const endAt = BigInt(decoded[5].toString());
106452
- const treasury = decoded[6];
106453
- const enabled = Boolean(decoded[7]);
106454
- return {
106455
- asset,
106456
- seriesId,
106457
- unitPrice,
106458
- remainingUnits,
106459
- startAt,
106460
- endAt,
106461
- treasury,
106462
- enabled
106463
- };
106464
- }
106465
- /**
106466
- * USDR로 투자 (approve 필요. autoApprove 옵션 제공)
106467
- * - Router.buy(offeringId, units, maxCost) 호출
106468
- */
106469
- async investRbtWithUsdr(params) {
106470
- this.assertHexAddress(params.usdrAddress, "usdrAddress");
106471
- this.assertHexAddress(params.saleRouterAddress, "saleRouterAddress");
106472
- const chainId = await this.resolveChainId(params.networkId);
106473
- const offeringId = this.toBigInt(params.offeringId, "offeringId");
106474
- const units = this.toBigInt(params.units, "units");
106475
- if (units <= 0n) {
106476
- throw new SDKError("Invalid units", "INVALID_PARAMS" /* INVALID_PARAMS */);
106477
- }
106478
- const offering = await this.getOffering({
106479
- networkId: params.networkId,
106480
- saleRouterAddress: params.saleRouterAddress,
106481
- offeringId
106482
- });
106483
- if (!offering.enabled) {
106484
- throw new SDKError("Offering is disabled", "REQUEST_FAILED" /* REQUEST_FAILED */);
106485
- }
106486
- const cost = units * offering.unitPrice;
106487
- const maxCost = params.maxCostWei != null ? this.toBigInt(params.maxCostWei, "maxCostWei") : cost;
106488
- if (maxCost < cost) {
106489
- throw new SDKError(
106490
- "maxCostWei is less than required cost",
106491
- "INVALID_PARAMS" /* INVALID_PARAMS */
106492
- );
106493
- }
106494
- const buyer = await this.walletService.getAddress();
106495
- let approvalTxHash;
106496
- const autoApprove = params.autoApprove ?? true;
106497
- const approveMax = params.approveMax ?? true;
106498
- const waitForApprovalReceipt = params.waitForApprovalReceipt ?? true;
106499
- if (autoApprove) {
106500
- const allowanceData = this.erc20Interface.encodeFunctionData(
106501
- "allowance",
106502
- [buyer, params.saleRouterAddress]
106503
- );
106504
- const allowanceHex = await this.ethCall(
106505
- chainId,
106506
- params.usdrAddress,
106507
- allowanceData
106508
- );
106509
- const allowanceDecoded = this.erc20Interface.decodeFunctionResult(
106510
- "allowance",
106511
- allowanceHex
106512
- );
106513
- const allowance = BigInt(allowanceDecoded[0].toString());
106514
- if (allowance < cost) {
106515
- const approveAmount = approveMax ? MAX_UINT256 : cost;
106516
- const approveData = this.erc20Interface.encodeFunctionData("approve", [
106517
- params.saleRouterAddress,
106518
- approveAmount.toString()
106519
- ]);
106520
- approvalTxHash = await this.walletService.sendTransaction({
106521
- to: params.usdrAddress,
106522
- value: "0",
106523
- data: approveData,
106524
- chainId,
106525
- gasLimit: params.gasLimitApprove
106526
- });
106527
- this.trackTransaction(approvalTxHash, chainId);
106528
- if (waitForApprovalReceipt) {
106529
- const ok = await this.waitForSuccessReceipt(approvalTxHash, chainId);
106530
- if (!ok) {
106531
- throw new SDKError(
106532
- "Approve transaction failed",
106533
- "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
106534
- );
106535
- }
106536
- }
106537
- }
106538
- }
106539
- const buyData = this.saleInterface.encodeFunctionData("buy", [
106540
- offeringId,
106541
- units,
106542
- maxCost
106543
- ]);
106544
- const purchaseTxHash = await this.walletService.sendTransaction({
106545
- to: params.saleRouterAddress,
106546
- value: "0",
106547
- data: buyData,
106548
- chainId,
106549
- gasLimit: params.gasLimitBuy
106550
- });
106551
- this.trackTransaction(purchaseTxHash, chainId);
106552
- return {
106553
- offering,
106554
- costWei: cost.toString(),
106555
- approvalTxHash,
106556
- purchaseTxHash
106557
- };
106558
- }
106559
- /**
106560
- * RBT 수익(이자) claim
106561
- * - RBTPropertyToken.claim(seriesId)
106562
- */
106563
- async claimRbtRevenue(params) {
106564
- this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
106565
- const chainId = await this.resolveChainId(params.networkId);
106566
- const seriesId = this.toBigInt(params.seriesId, "seriesId");
106567
- const claimData = this.rbtInterface.encodeFunctionData("claim", [seriesId]);
106568
- const txHash = await this.walletService.sendTransaction({
106569
- to: params.rbtAssetAddress,
106570
- value: "0",
106571
- data: claimData,
106572
- chainId,
106573
- gasLimit: params.gasLimit
106574
- });
106575
- this.trackTransaction(txHash, chainId);
106576
- return { txHash };
106577
- }
106578
- /**
106579
- * claimable 조회 (eth_call)
106580
- */
106581
- async getClaimable(params) {
106582
- this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
106583
- const chainId = await this.resolveChainId(params.networkId);
106584
- const seriesId = this.toBigInt(params.seriesId, "seriesId");
106585
- const account = params.account ?? await this.walletService.getAddress();
106586
- this.assertHexAddress(account, "account");
106587
- const data = this.rbtInterface.encodeFunctionData("claimable", [
106588
- seriesId,
106589
- account
106590
- ]);
106591
- const result = await this.ethCall(chainId, params.rbtAssetAddress, data);
106592
- const decoded = this.rbtInterface.decodeFunctionResult("claimable", result);
106593
- return BigInt(decoded[0].toString()).toString();
106594
- }
106595
- /**
106596
- * RBT balanceOf 조회 (eth_call)
106597
- */
106598
- async getRbtBalance(params) {
106599
- this.assertHexAddress(params.rbtAssetAddress, "rbtAssetAddress");
106600
- const chainId = await this.resolveChainId(params.networkId);
106601
- const seriesId = this.toBigInt(params.seriesId, "seriesId");
106602
- const account = params.account ?? await this.walletService.getAddress();
106603
- this.assertHexAddress(account, "account");
106604
- const data = this.rbtInterface.encodeFunctionData("balanceOf", [
106605
- account,
106606
- seriesId
106607
- ]);
106608
- const result = await this.ethCall(chainId, params.rbtAssetAddress, data);
106609
- const decoded = this.rbtInterface.decodeFunctionResult("balanceOf", result);
106610
- return BigInt(decoded[0].toString()).toString();
106611
- }
106612
- async waitForSuccessReceipt(txHash, chainId) {
106613
- let retryCount = 0;
106614
- const MAX_RETRIES = 20;
106615
- while (retryCount < MAX_RETRIES) {
106616
- const res = await this.rpcClient.sendRpc({
106617
- chainId,
106618
- method: "eth_getTransactionReceipt" /* ETH_GET_TRANSACTION_RECEIPT */,
106619
- params: [txHash]
106620
- });
106621
- if (res.result) {
106622
- return res.result.status === "0x1";
106623
- }
106624
- retryCount++;
106625
- await new Promise((r5) => setTimeout$1(r5, 3e3));
106626
- }
106627
- return false;
106628
- }
106629
- trackTransaction(txHash, chainId) {
106630
- let retryCount = 0;
106631
- const MAX_RETRIES = 20;
106632
- const checkStatus = async () => {
106633
- try {
106634
- const response = await this.rpcClient.sendRpc({
106635
- chainId,
106636
- method: "eth_getTransactionReceipt" /* ETH_GET_TRANSACTION_RECEIPT */,
106637
- params: [txHash]
106638
- });
106639
- if (response.result) {
106640
- const status = response.result.status === "0x1" ? "SUCCESS" /* SUCCESS */ : "FAILED" /* FAILED */;
106641
- this.emit("transactionStatusChanged", {
106642
- hash: txHash,
106643
- status,
106644
- timestamp: Date.now()
106645
- });
106646
- return;
106647
- }
106648
- retryCount++;
106649
- if (retryCount < MAX_RETRIES) {
106650
- setTimeout$1(checkStatus, 3e3);
106651
- } else {
106652
- this.emit("transactionStatusChanged", {
106653
- hash: txHash,
106654
- status: "FAILED" /* FAILED */,
106655
- timestamp: Date.now(),
106656
- error: "Transaction timeout"
106657
- });
106658
- }
106659
- } catch (error) {
106660
- this.emit("transactionStatusChanged", {
106661
- hash: txHash,
106662
- status: "FAILED" /* FAILED */,
106663
- timestamp: Date.now(),
106664
- error: error instanceof Error ? error.message : "Unknown error"
106665
- });
106666
- }
106667
- };
106668
- checkStatus();
106669
- }
106670
- };
106671
-
106672
106410
  // src/core/internal.ts
106673
106411
  var InternalCoreImpl = class {
106674
106412
  constructor(options) {
@@ -106708,9 +106446,22 @@ var InternalCoreImpl = class {
106708
106446
  addToken: (params) => this.assetService.addToken(params),
106709
106447
  // New ERC20 methods
106710
106448
  getTokenBalance: (params) => this.assetService.getTokenBalance(params),
106449
+ // ERC1155 / RBT helpers
106450
+ getERC1155Balance: (params) => this.assetService.getERC1155Balance(params),
106451
+ getRbtClaimable: (params) => this.assetService.getRbtClaimable(params),
106452
+ claimRbt: (params) => this.assetService.claimRbt(params),
106711
106453
  approveToken: (params) => this.assetService.approveToken(params),
106712
106454
  getAllowance: (params) => this.assetService.getAllowance(params),
106455
+ // getTokenInfo: (params: TokenInfoParams) =>
106456
+ // this.assetService.getTokenInfo(params),
106713
106457
  addNFTCollection: (params) => this.assetService.addNFTCollection(params),
106458
+ // checkSecurityTokenCompliance: (params: {
106459
+ // networkId: string
106460
+ // tokenAddress: string
106461
+ // from: string
106462
+ // to: string
106463
+ // amount: string
106464
+ // }) => this.assetService.checkSecurityTokenCompliance(params),
106714
106465
  on: (event, listener) => this.assetService.on(event, listener),
106715
106466
  off: (event, listener) => this.assetService.off(event, listener),
106716
106467
  getTokenInfo: (params) => this.assetService.getTokenInfo(params),
@@ -106718,15 +106469,6 @@ var InternalCoreImpl = class {
106718
106469
  getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params),
106719
106470
  getRegisteredCoins: (networkId) => this.assetService.getRegisteredCoins(networkId)
106720
106471
  };
106721
- this.investment = {
106722
- getOffering: (params) => this.investmentService.getOffering(params),
106723
- investRbtWithUsdr: (params) => this.investmentService.investRbtWithUsdr(params),
106724
- claimRbtRevenue: (params) => this.investmentService.claimRbtRevenue(params),
106725
- getClaimable: (params) => this.investmentService.getClaimable(params),
106726
- getRbtBalance: (params) => this.investmentService.getRbtBalance(params),
106727
- on: (event, listener) => this.investmentService.on(event, listener),
106728
- off: (event, listener) => this.investmentService.off(event, listener)
106729
- };
106730
106472
  const httpClient = new HttpClient(options);
106731
106473
  const firebase = new FirebaseAuth(options);
106732
106474
  const userClient = new UserClient(httpClient);
@@ -106752,11 +106494,6 @@ var InternalCoreImpl = class {
106752
106494
  userClient,
106753
106495
  options.orgHost
106754
106496
  );
106755
- this.investmentService = new InvestmentService(
106756
- rpcClient,
106757
- this.walletService,
106758
- this.networkService
106759
- );
106760
106497
  }
106761
106498
  };
106762
106499
 
@@ -107009,6 +106746,15 @@ var AssetModule = class {
107009
106746
  async getTokenBalance(params) {
107010
106747
  return this.core.asset.getTokenBalance(params);
107011
106748
  }
106749
+ async getERC1155Balance(params) {
106750
+ return this.core.asset.getERC1155Balance(params);
106751
+ }
106752
+ async getRbtClaimable(params) {
106753
+ return this.core.asset.getRbtClaimable(params);
106754
+ }
106755
+ async claimRbt(params) {
106756
+ return this.core.asset.claimRbt(params);
106757
+ }
107012
106758
  async approveToken(params) {
107013
106759
  return this.core.asset.approveToken(params);
107014
106760
  }
@@ -107032,35 +106778,6 @@ var AssetModule = class {
107032
106778
  }
107033
106779
  };
107034
106780
 
107035
- // src/modules/Investment.ts
107036
- var InvestmentModule = class {
107037
- constructor(options, core) {
107038
- this.options = options;
107039
- this.core = core;
107040
- }
107041
- getOffering(params) {
107042
- return this.core.investment.getOffering(params);
107043
- }
107044
- investRbtWithUsdr(params) {
107045
- return this.core.investment.investRbtWithUsdr(params);
107046
- }
107047
- claimRbtRevenue(params) {
107048
- return this.core.investment.claimRbtRevenue(params);
107049
- }
107050
- getClaimable(params) {
107051
- return this.core.investment.getClaimable(params);
107052
- }
107053
- getRbtBalance(params) {
107054
- return this.core.investment.getRbtBalance(params);
107055
- }
107056
- on(event, listener) {
107057
- this.core.investment.on(event, listener);
107058
- }
107059
- off(event, listener) {
107060
- this.core.investment.off(event, listener);
107061
- }
107062
- };
107063
-
107064
106781
  // src/utils/network.ts
107065
106782
  var KNOWN_NETWORKS = {
107066
106783
  1: {
@@ -107128,134 +106845,88 @@ var WeBlockSDK = class {
107128
106845
  this.initialized = false;
107129
106846
  this.user = {
107130
106847
  signIn: async (provider) => {
107131
- this.ensureInitialized();
107132
106848
  return this.userModule.signIn(provider);
107133
106849
  },
107134
106850
  createWallet: async (password) => {
107135
- this.ensureInitialized();
107136
106851
  return this.userModule.createWallet(password);
107137
106852
  },
107138
106853
  retrieveWallet: async (password) => {
107139
- this.ensureInitialized();
107140
106854
  return this.userModule.retrieveWallet(password);
107141
106855
  },
107142
106856
  /**
107143
106857
  * ✅ 추가: PIN reset API 노출
107144
106858
  */
107145
106859
  resetPin: async (newPassword) => {
107146
- this.ensureInitialized();
107147
106860
  return this.userModule.resetPin(newPassword);
107148
106861
  },
107149
106862
  signOut: async () => {
107150
- this.ensureInitialized();
107151
106863
  return this.userModule.signOut();
107152
106864
  }
107153
106865
  };
107154
106866
  this.wallet = {
107155
106867
  getInfo: async () => {
107156
- this.ensureInitialized();
107157
106868
  return this.walletModule.getInfo();
107158
106869
  },
107159
106870
  onWalletUpdate: (callback) => {
107160
- this.ensureInitialized();
107161
106871
  return this.walletModule.onWalletUpdate(callback);
107162
106872
  },
107163
106873
  onTransactionUpdate: (callback) => {
107164
- this.ensureInitialized();
107165
106874
  return this.walletModule.onTransactionUpdate(callback);
107166
106875
  },
107167
106876
  getBalance: (address, chainId) => {
107168
- this.ensureInitialized();
107169
106877
  return this.walletModule.getBalance(address, chainId);
107170
106878
  },
107171
106879
  getTransactionCount: (address, chainId) => {
107172
- this.ensureInitialized();
107173
106880
  return this.walletModule.getTransactionCount(address, chainId);
107174
106881
  },
107175
106882
  getBlockNumber: (chainId) => {
107176
- this.ensureInitialized();
107177
106883
  return this.walletModule.getBlockNumber(chainId);
107178
106884
  },
107179
106885
  sendRawTransaction: (signedTx, chainId) => {
107180
- this.ensureInitialized();
107181
106886
  return this.walletModule.sendRawTransaction(signedTx, chainId);
107182
106887
  },
107183
106888
  getTransactionReceipt: (txHash, chainId) => {
107184
- this.ensureInitialized();
107185
106889
  return this.walletModule.getTransactionReceipt(txHash, chainId);
107186
106890
  },
107187
106891
  getTransaction: (txHash, chainId) => {
107188
- this.ensureInitialized();
107189
106892
  return this.walletModule.getTransaction(txHash, chainId);
107190
106893
  },
107191
106894
  estimateGas: (txParams, chainId) => {
107192
- this.ensureInitialized();
107193
106895
  return this.walletModule.estimateGas(txParams, chainId);
107194
106896
  },
107195
106897
  getGasPrice: (chainId) => {
107196
- this.ensureInitialized();
107197
106898
  return this.walletModule.getGasPrice(chainId);
107198
106899
  },
107199
106900
  call: (txParams, blockParam, chainId) => {
107200
- this.ensureInitialized();
107201
106901
  return this.walletModule.call(txParams, blockParam, chainId);
107202
106902
  }
107203
106903
  };
107204
106904
  this.network = {
107205
- getAvailableNetworks: () => {
107206
- this.ensureInitialized();
107207
- return this.networkModule.getAvailableNetworks();
107208
- },
107209
- addNetwork: (request) => {
107210
- this.ensureInitialized();
107211
- return this.networkModule.addNetwork(request);
107212
- },
107213
- switchNetwork: (networkId) => {
107214
- this.ensureInitialized();
107215
- return this.networkModule.switchNetwork(networkId);
107216
- },
107217
- getCurrentNetwork: () => {
107218
- this.ensureInitialized();
107219
- return this.networkModule.getCurrentNetwork();
107220
- }
106905
+ getAvailableNetworks: () => this.networkModule.getAvailableNetworks(),
106906
+ addNetwork: (request) => this.networkModule.addNetwork(request),
106907
+ switchNetwork: (networkId) => this.networkModule.switchNetwork(networkId),
106908
+ getCurrentNetwork: () => this.networkModule.getCurrentNetwork()
107221
106909
  };
107222
106910
  this.asset = {
107223
106911
  transfer: async (params) => {
107224
- this.ensureInitialized();
107225
106912
  return this.assetModule.transfer(params);
107226
106913
  },
107227
106914
  addToken: async (params) => {
107228
- this.ensureInitialized();
107229
106915
  return this.assetModule.addToken(params);
107230
106916
  },
107231
106917
  addNFTCollection: async (params) => {
107232
- this.ensureInitialized();
107233
106918
  return this.assetModule.addNFTCollection(params);
107234
106919
  },
107235
106920
  on: (event, listener) => {
107236
- this.ensureInitialized();
107237
106921
  this.assetModule.on(event, listener);
107238
106922
  },
107239
106923
  off: (event, listener) => {
107240
- this.ensureInitialized();
107241
106924
  this.assetModule.off(event, listener);
107242
106925
  },
107243
106926
  getTokenInfo: async (params) => {
107244
- this.ensureInitialized();
107245
106927
  return this.assetModule.getTokenInfo(params);
107246
106928
  },
107247
- registerToken: async (params) => {
107248
- this.ensureInitialized();
107249
- return this.assetModule.registerToken(params);
107250
- },
107251
- getTokenFullInfo: async (params) => {
107252
- this.ensureInitialized();
107253
- return this.assetModule.getTokenFullInfo(params);
107254
- },
107255
- /**
107256
- * ✅ ERC20 잔액 조회 (주의: 현재 AssetModule 구현은 raw balance string을 반환)
107257
- * - TokenBalance(객체)가 아니라 string(wei) 입니다.
107258
- */
106929
+ // ERC20 helpers
107259
106930
  getTokenBalance: async (params) => {
107260
106931
  this.ensureInitialized();
107261
106932
  return this.assetModule.getTokenBalance(params);
@@ -107267,39 +106938,25 @@ var WeBlockSDK = class {
107267
106938
  getAllowance: async (params) => {
107268
106939
  this.ensureInitialized();
107269
106940
  return this.assetModule.getAllowance(params);
107270
- }
107271
- };
107272
- /**
107273
- * ✅ NEW: Investment API Surface
107274
- */
107275
- this.invest = {
107276
- getOffering: async (params) => {
107277
- this.ensureInitialized();
107278
- return this.investmentModule.getOffering(params);
107279
106941
  },
107280
- investRbtWithUsdr: async (params) => {
106942
+ // ERC1155 / RBT helpers
106943
+ getERC1155Balance: async (params) => {
107281
106944
  this.ensureInitialized();
107282
- return this.investmentModule.investRbtWithUsdr(params);
106945
+ return this.assetModule.getERC1155Balance(params);
107283
106946
  },
107284
- claimRbtRevenue: async (params) => {
106947
+ getRbtClaimable: async (params) => {
107285
106948
  this.ensureInitialized();
107286
- return this.investmentModule.claimRbtRevenue(params);
106949
+ return this.assetModule.getRbtClaimable(params);
107287
106950
  },
107288
- getClaimable: async (params) => {
106951
+ claimRbt: async (params) => {
107289
106952
  this.ensureInitialized();
107290
- return this.investmentModule.getClaimable(params);
106953
+ return this.assetModule.claimRbt(params);
107291
106954
  },
107292
- getRbtBalance: async (params) => {
107293
- this.ensureInitialized();
107294
- return this.investmentModule.getRbtBalance(params);
107295
- },
107296
- on: (event, listener) => {
107297
- this.ensureInitialized();
107298
- this.investmentModule.on(event, listener);
106955
+ registerToken: async (params) => {
106956
+ return this.assetModule.registerToken(params);
107299
106957
  },
107300
- off: (event, listener) => {
107301
- this.ensureInitialized();
107302
- this.investmentModule.off(event, listener);
106958
+ getTokenFullInfo: async (params) => {
106959
+ return this.assetModule.getTokenFullInfo(params);
107303
106960
  }
107304
106961
  };
107305
106962
  this.validateOptions(options);
@@ -107309,7 +106966,6 @@ var WeBlockSDK = class {
107309
106966
  this.userModule = new UserModule(options, internalCore, this.walletModule);
107310
106967
  this.assetModule = new AssetModule(options, internalCore);
107311
106968
  this.networkModule = new NetworkModule(options, internalCore);
107312
- this.investmentModule = new InvestmentModule(options, internalCore);
107313
106969
  this.initialized = true;
107314
106970
  console.info("WeBlock SDK initialized successfully");
107315
106971
  }
@@ -107318,15 +106974,13 @@ var WeBlockSDK = class {
107318
106974
  if (!["local", "dev", "stage", "prod"].includes(environment)) {
107319
106975
  throw new SDKError("Invalid environment", "INVALID_CONFIG" /* INVALID_CONFIG */);
107320
106976
  }
107321
- if (!apiKey) {
106977
+ if (!apiKey)
107322
106978
  throw new SDKError("API key is required", "INVALID_CONFIG" /* INVALID_CONFIG */);
107323
- }
107324
- if (!orgHost) {
106979
+ if (!orgHost)
107325
106980
  throw new SDKError(
107326
106981
  "Organization host is required",
107327
106982
  "INVALID_CONFIG" /* INVALID_CONFIG */
107328
106983
  );
107329
- }
107330
106984
  }
107331
106985
  ensureInitialized() {
107332
106986
  if (!this.initialized) {