@weblock-wallet/sdk 0.1.47 → 0.1.48

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 CHANGED
@@ -106061,9 +106061,44 @@ var AssetService = class extends EventEmitter {
106061
106061
  checkStatus();
106062
106062
  }
106063
106063
  async addToken(params) {
106064
+ const hasMeta = !!params.name && !!params.symbol && typeof params.decimals === "number";
106065
+ const meta = hasMeta ? {
106066
+ name: params.name,
106067
+ symbol: params.symbol,
106068
+ decimals: params.decimals
106069
+ } : await this.getTokenInfo({
106070
+ networkId: params.networkId,
106071
+ tokenAddress: params.address
106072
+ });
106073
+ try {
106074
+ await this.userClient.registerToken({
106075
+ blockchainId: params.networkId,
106076
+ contractAddress: params.address,
106077
+ name: meta.name,
106078
+ symbol: meta.symbol,
106079
+ decimals: meta.decimals
106080
+ });
106081
+ } catch (error) {
106082
+ throw new SDKError(
106083
+ "Failed to register token",
106084
+ "REQUEST_FAILED" /* REQUEST_FAILED */,
106085
+ error
106086
+ );
106087
+ }
106064
106088
  const key = `${this.orgHost}:token:${params.networkId}:${params.address}`;
106065
106089
  await LocalForage.save(key, params);
106066
106090
  }
106091
+ async getRegisteredCoins(networkId) {
106092
+ try {
106093
+ return await this.userClient.getRegisteredCoins(networkId);
106094
+ } catch (error) {
106095
+ throw new SDKError(
106096
+ "Failed to get registered tokens",
106097
+ "REQUEST_FAILED" /* REQUEST_FAILED */,
106098
+ error
106099
+ );
106100
+ }
106101
+ }
106067
106102
  async getTokenBalance(params) {
106068
106103
  try {
106069
106104
  const chainId = await this.resolveChainId(params.networkId);
@@ -106175,6 +106210,19 @@ var AssetService = class extends EventEmitter {
106175
106210
  const key = `${this.orgHost}:nft:${params.networkId}:${params.address}`;
106176
106211
  await LocalForage.save(key, params);
106177
106212
  }
106213
+ // async checkSecurityTokenCompliance(params: {
106214
+ // networkId: string
106215
+ // tokenAddress: string
106216
+ // from: string
106217
+ // to: string
106218
+ // amount: string
106219
+ // }): Promise<{
106220
+ // canTransfer: boolean
106221
+ // reasons?: string[]
106222
+ // }> {
106223
+ // // TODO: Implement security token compliance check
106224
+ // return { canTransfer: true }
106225
+ // }
106178
106226
  };
106179
106227
 
106180
106228
  // src/core/internal.ts
@@ -106192,7 +106240,6 @@ var InternalCoreImpl = class {
106192
106240
  getAddress: () => this.walletService.getAddress(),
106193
106241
  create: (password) => this.walletService.create(password),
106194
106242
  retrieveWallet: (password) => this.walletService.retrieveWallet(password),
106195
- resetPin: (newPassword) => this.walletService.resetPin(newPassword),
106196
106243
  getBalance: (address, chainId) => this.walletService.getBalance(address, chainId),
106197
106244
  getTokenBalance: (tokenAddress, walletAddress, chainId) => this.walletService.getTokenBalance(tokenAddress, walletAddress, chainId),
106198
106245
  sendTransaction: (params) => this.walletService.sendTransaction(params),
@@ -106214,25 +106261,27 @@ var InternalCoreImpl = class {
106214
106261
  };
106215
106262
  this.asset = {
106216
106263
  transfer: (params) => this.assetService.transfer(params),
106217
- /**
106218
- * 타입 정합성:
106219
- * - InternalCore는 decimals?: number
106220
- * - 기존 AssetService 내부 구현이 decimals를 string으로 받는 경우가 있어,
106221
- * 여기서 안전하게 string으로 변환해서 전달합니다.
106222
- */
106223
- addToken: (params) => this.assetService.addToken({
106224
- ...params,
106225
- decimals: typeof params.decimals === "number" ? String(params.decimals) : void 0
106226
- }),
106264
+ addToken: (params) => this.assetService.addToken(params),
106265
+ // New ERC20 methods
106227
106266
  getTokenBalance: (params) => this.assetService.getTokenBalance(params),
106228
106267
  approveToken: (params) => this.assetService.approveToken(params),
106229
106268
  getAllowance: (params) => this.assetService.getAllowance(params),
106269
+ // getTokenInfo: (params: TokenInfoParams) =>
106270
+ // this.assetService.getTokenInfo(params),
106230
106271
  addNFTCollection: (params) => this.assetService.addNFTCollection(params),
106272
+ // checkSecurityTokenCompliance: (params: {
106273
+ // networkId: string
106274
+ // tokenAddress: string
106275
+ // from: string
106276
+ // to: string
106277
+ // amount: string
106278
+ // }) => this.assetService.checkSecurityTokenCompliance(params),
106231
106279
  on: (event, listener) => this.assetService.on(event, listener),
106232
106280
  off: (event, listener) => this.assetService.off(event, listener),
106233
106281
  getTokenInfo: (params) => this.assetService.getTokenInfo(params),
106234
106282
  registerToken: (params) => this.assetService.registerToken(params),
106235
- getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params)
106283
+ getTokenFullInfo: (params) => this.assetService.getTokenFullInfo(params),
106284
+ getRegisteredCoins: (networkId) => this.assetService.getRegisteredCoins(networkId)
106236
106285
  };
106237
106286
  const httpClient = new HttpClient(options);
106238
106287
  const firebase = new FirebaseAuth(options);
@@ -106387,6 +106436,34 @@ var WalletModule = class {
106387
106436
  network.chainId
106388
106437
  );
106389
106438
  console.log("\uCD5C\uADFC \uD2B8\uB79C\uC7AD\uC158:", latestTransaction);
106439
+ let tokens = [];
106440
+ try {
106441
+ const registered = await this.core.asset.getRegisteredCoins(network.id);
106442
+ if (registered?.length) {
106443
+ const unique = new Map(
106444
+ registered.map((c5) => [c5.contractAddress.toLowerCase(), c5])
106445
+ );
106446
+ tokens = await Promise.all(
106447
+ Array.from(unique.values()).map(async (coin) => {
106448
+ const full = await this.core.asset.getTokenFullInfo({
106449
+ networkId: network.id,
106450
+ tokenAddress: coin.contractAddress,
106451
+ walletAddress: address
106452
+ });
106453
+ return {
106454
+ ...full,
106455
+ address: coin.contractAddress,
106456
+ name: coin.name ?? full.name,
106457
+ symbol: coin.symbol ?? full.symbol,
106458
+ decimals: typeof coin.decimals === "number" ? coin.decimals : full.decimals
106459
+ };
106460
+ })
106461
+ );
106462
+ }
106463
+ } catch (e7) {
106464
+ console.warn("Registered token load failed:", e7);
106465
+ tokens = [];
106466
+ }
106390
106467
  const walletInfo = {
106391
106468
  address,
106392
106469
  network: {
@@ -106399,40 +106476,7 @@ var WalletModule = class {
106399
106476
  balance: nativeBalance,
106400
106477
  decimals: 18
106401
106478
  },
106402
- tokens: [
106403
- // {
106404
- // symbol: rbtBalance.symbol,
106405
- // name: 'Real-estate Backed Token',
106406
- // address: '0xB10536cC40Cb6E6415f70d3a4C1AF7Fa638AE829',
106407
- // balance: rbtBalance,
106408
- // decimals: rbtBalance.decimals,
106409
- // totalSupply: rbtBalance,
106410
- // },
106411
- // {
106412
- // symbol: usdrBalance.symbol,
106413
- // name: 'USD Real-estate',
106414
- // address: '0x8d335fe5B30e27F2B21F057a4766cf4BB8c30785',
106415
- // balance: usdrBalance,
106416
- // decimals: usdrBalance.decimals,
106417
- // totalSupply: usdrBalance,
106418
- // },
106419
- // {
106420
- // symbol: wftBalance.symbol,
106421
- // name: 'WeBlock Foundation Token',
106422
- // address: '0x6fa62Eda03956ef4E54f3C8597E8c3f3bE40A45B',
106423
- // balance: wftBalance,
106424
- // decimals: wftBalance.decimals,
106425
- // totalSupply: wftBalance,
106426
- // },
106427
- // {
106428
- // symbol: usdtBalance.symbol,
106429
- // name: 'USD Tether',
106430
- // address: '0xfF54B9ebe777f528E64C74bc95c68433B7546038',
106431
- // balance: usdtBalance,
106432
- // decimals: usdtBalance.decimals,
106433
- // totalSupply: usdtBalance,
106434
- // },
106435
- ],
106479
+ tokens,
106436
106480
  nfts: [],
106437
106481
  securities: []
106438
106482
  },