@weblock-wallet/sdk 0.1.45 → 0.1.47

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.cts CHANGED
@@ -421,6 +421,10 @@ declare class WeBlockSDK {
421
421
  signIn: (provider: "google.com") => Promise<SignInResponse>;
422
422
  createWallet: (password: string) => Promise<WalletResponse>;
423
423
  retrieveWallet: (password: string) => Promise<WalletResponse>;
424
+ /**
425
+ * ✅ 추가: PIN reset API 노출
426
+ */
427
+ resetPin: (newPassword: string) => Promise<WalletResponse>;
424
428
  signOut: () => Promise<void>;
425
429
  };
426
430
  readonly wallet: {
@@ -458,23 +462,6 @@ declare class WeBlockSDK {
458
462
  address: string;
459
463
  name?: string;
460
464
  }) => Promise<void>;
461
- getTokenBalance: (params: {
462
- networkId: string;
463
- tokenAddress: string;
464
- walletAddress: string;
465
- }) => Promise<string>;
466
- approveToken: (params: {
467
- networkId: string;
468
- tokenAddress: string;
469
- spender: string;
470
- amount: string;
471
- }) => Promise<string>;
472
- getAllowance: (params: {
473
- networkId: string;
474
- tokenAddress: string;
475
- owner: string;
476
- spender: string;
477
- }) => Promise<string>;
478
465
  on: (event: string, listener: (...args: any[]) => void) => void;
479
466
  off: (event: string, listener: (...args: any[]) => void) => void;
480
467
  getTokenInfo: (params: TokenInfoParams) => Promise<TokenMetadata>;
package/dist/index.d.ts CHANGED
@@ -421,6 +421,10 @@ declare class WeBlockSDK {
421
421
  signIn: (provider: "google.com") => Promise<SignInResponse>;
422
422
  createWallet: (password: string) => Promise<WalletResponse>;
423
423
  retrieveWallet: (password: string) => Promise<WalletResponse>;
424
+ /**
425
+ * ✅ 추가: PIN reset API 노출
426
+ */
427
+ resetPin: (newPassword: string) => Promise<WalletResponse>;
424
428
  signOut: () => Promise<void>;
425
429
  };
426
430
  readonly wallet: {
@@ -458,23 +462,6 @@ declare class WeBlockSDK {
458
462
  address: string;
459
463
  name?: string;
460
464
  }) => Promise<void>;
461
- getTokenBalance: (params: {
462
- networkId: string;
463
- tokenAddress: string;
464
- walletAddress: string;
465
- }) => Promise<string>;
466
- approveToken: (params: {
467
- networkId: string;
468
- tokenAddress: string;
469
- spender: string;
470
- amount: string;
471
- }) => Promise<string>;
472
- getAllowance: (params: {
473
- networkId: string;
474
- tokenAddress: string;
475
- owner: string;
476
- spender: string;
477
- }) => Promise<string>;
478
465
  on: (event: string, listener: (...args: any[]) => void) => void;
479
466
  off: (event: string, listener: (...args: any[]) => void) => void;
480
467
  getTokenInfo: (params: TokenInfoParams) => Promise<TokenMetadata>;
package/dist/index.js CHANGED
@@ -105785,8 +105785,51 @@ var AssetService = class extends EventEmitter {
105785
105785
  this.networkService = networkService;
105786
105786
  this.userClient = userClient;
105787
105787
  this.orgHost = orgHost;
105788
+ this.chainIdCache = /* @__PURE__ */ new Map();
105788
105789
  this.erc20Interface = new Interface2(ERC20_ABI2);
105789
105790
  }
105791
+ /**
105792
+ * Resolve a user-facing networkId (blockchainId) into an EVM chainId for /v1/rpcs.
105793
+ *
105794
+ * Notes
105795
+ * - Many SDK APIs use `networkId` to mean the registered blockchain id (UUID).
105796
+ * - The wallet-rpc endpoint (/v1/rpcs) expects `chainId`.
105797
+ * - Some older call-sites may pass chainId as a string; we support both.
105798
+ */
105799
+ async resolveChainId(networkId) {
105800
+ const trimmed = (networkId ?? "").trim();
105801
+ const cached = this.chainIdCache.get(trimmed);
105802
+ if (cached) return cached;
105803
+ const numeric = Number(trimmed);
105804
+ if (!Number.isNaN(numeric) && Number.isFinite(numeric) && numeric > 0) {
105805
+ this.chainIdCache.set(trimmed, numeric);
105806
+ return numeric;
105807
+ }
105808
+ try {
105809
+ const current = await this.networkService.getCurrentNetwork();
105810
+ if (current && current.id === trimmed) {
105811
+ this.chainIdCache.set(trimmed, current.chainId);
105812
+ return current.chainId;
105813
+ }
105814
+ if (current && String(current.chainId) === trimmed) {
105815
+ this.chainIdCache.set(trimmed, current.chainId);
105816
+ return current.chainId;
105817
+ }
105818
+ } catch {
105819
+ }
105820
+ const networks = await this.networkService.getRegisteredNetworks();
105821
+ const found = networks.find((n5) => n5.id === trimmed);
105822
+ if (found) {
105823
+ this.chainIdCache.set(trimmed, found.chainId);
105824
+ return found.chainId;
105825
+ }
105826
+ const foundByChainId = networks.find((n5) => String(n5.chainId) === trimmed);
105827
+ if (foundByChainId) {
105828
+ this.chainIdCache.set(trimmed, foundByChainId.chainId);
105829
+ return foundByChainId.chainId;
105830
+ }
105831
+ throw new SDKError("Invalid network", "INVALID_NETWORK" /* INVALID_NETWORK */);
105832
+ }
105790
105833
  async getTokenInfo(params) {
105791
105834
  try {
105792
105835
  const [name2, symbol, decimals] = await Promise.all([
@@ -105982,11 +106025,12 @@ var AssetService = class extends EventEmitter {
105982
106025
  }
105983
106026
  async getTokenBalance(params) {
105984
106027
  try {
106028
+ const chainId = await this.resolveChainId(params.networkId);
105985
106029
  const data = this.erc20Interface.encodeFunctionData("balanceOf", [
105986
106030
  params.walletAddress
105987
106031
  ]);
105988
106032
  const response = await this.rpcClient.sendRpc({
105989
- chainId: Number(params.networkId),
106033
+ chainId,
105990
106034
  method: "eth_call" /* ETH_CALL */,
105991
106035
  params: [
105992
106036
  {
@@ -106007,12 +106051,13 @@ var AssetService = class extends EventEmitter {
106007
106051
  }
106008
106052
  async approveToken(params) {
106009
106053
  try {
106054
+ const chainId = await this.resolveChainId(params.networkId);
106010
106055
  const data = this.erc20Interface.encodeFunctionData("approve", [
106011
106056
  params.spender,
106012
106057
  params.amount
106013
106058
  ]);
106014
106059
  const response = await this.rpcClient.sendRpc({
106015
- chainId: Number(params.networkId),
106060
+ chainId,
106016
106061
  method: "eth_sendRawTransaction" /* ETH_SEND_RAW_TRANSACTION */,
106017
106062
  params: [
106018
106063
  {
@@ -106032,12 +106077,13 @@ var AssetService = class extends EventEmitter {
106032
106077
  }
106033
106078
  async getAllowance(params) {
106034
106079
  try {
106080
+ const chainId = await this.resolveChainId(params.networkId);
106035
106081
  const data = this.erc20Interface.encodeFunctionData("allowance", [
106036
106082
  params.owner,
106037
106083
  params.spender
106038
106084
  ]);
106039
106085
  const response = await this.rpcClient.sendRpc({
106040
- chainId: Number(params.networkId),
106086
+ chainId,
106041
106087
  method: "eth_call" /* ETH_CALL */,
106042
106088
  params: [
106043
106089
  {
@@ -106057,9 +106103,10 @@ var AssetService = class extends EventEmitter {
106057
106103
  }
106058
106104
  }
106059
106105
  async callTokenMethod(tokenAddress, networkId, method) {
106106
+ const chainId = await this.resolveChainId(networkId);
106060
106107
  const data = this.erc20Interface.encodeFunctionData(method, []);
106061
106108
  const response = await this.rpcClient.sendRpc({
106062
- chainId: Number(networkId),
106109
+ chainId,
106063
106110
  method: "eth_call" /* ETH_CALL */,
106064
106111
  params: [
106065
106112
  {
@@ -106087,19 +106134,6 @@ var AssetService = class extends EventEmitter {
106087
106134
  const key = `${this.orgHost}:nft:${params.networkId}:${params.address}`;
106088
106135
  await LocalForage.save(key, params);
106089
106136
  }
106090
- // async checkSecurityTokenCompliance(params: {
106091
- // networkId: string
106092
- // tokenAddress: string
106093
- // from: string
106094
- // to: string
106095
- // amount: string
106096
- // }): Promise<{
106097
- // canTransfer: boolean
106098
- // reasons?: string[]
106099
- // }> {
106100
- // // TODO: Implement security token compliance check
106101
- // return { canTransfer: true }
106102
- // }
106103
106137
  };
106104
106138
 
106105
106139
  // src/core/internal.ts
@@ -106539,6 +106573,12 @@ var WeBlockSDK = class {
106539
106573
  retrieveWallet: async (password) => {
106540
106574
  return this.userModule.retrieveWallet(password);
106541
106575
  },
106576
+ /**
106577
+ * ✅ 추가: PIN reset API 노출
106578
+ */
106579
+ resetPin: async (newPassword) => {
106580
+ return this.userModule.resetPin(newPassword);
106581
+ },
106542
106582
  signOut: async () => {
106543
106583
  return this.userModule.signOut();
106544
106584
  }
@@ -106597,37 +106637,6 @@ var WeBlockSDK = class {
106597
106637
  addNFTCollection: async (params) => {
106598
106638
  return this.assetModule.addNFTCollection(params);
106599
106639
  },
106600
- // checkSecurityTokenCompliance: async (params: {
106601
- // networkId: string
106602
- // tokenAddress: string
106603
- // from: string
106604
- // to: string
106605
- // amount: string
106606
- // }): Promise<{
106607
- // canTransfer: boolean
106608
- // reasons?: string[]
106609
- // }> => {
106610
- // return this.assetModule.checkSecurityTokenCompliance(params)
106611
- // },
106612
- getTokenBalance: async (params) => {
106613
- return this.assetModule.getTokenBalance(params);
106614
- },
106615
- approveToken: async (params) => {
106616
- return this.assetModule.approveToken(params);
106617
- },
106618
- getAllowance: async (params) => {
106619
- return this.assetModule.getAllowance(params);
106620
- },
106621
- // getTokenInfo: async (params: {
106622
- // networkId: string
106623
- // tokenAddress: string
106624
- // }): Promise<{
106625
- // name: string
106626
- // symbol: string
106627
- // decimals: number
106628
- // }> => {
106629
- // return this.assetModule.getTokenInfo(params)
106630
- // },
106631
106640
  on: (event, listener) => {
106632
106641
  this.assetModule.on(event, listener);
106633
106642
  },